Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <script>
    // declare vars so they are available outside of main()
    var canvas,
        ctx,
        width,
        height;
    
    var bird = {
        draw: function() {
            var birdimg = new Image();
            birdimg.src ="http://www.jqueryscript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg";
        
            birdimg.onload = function() {
                ctx.drawImage(birdimg, -20, height - 200);
            };
        }
    };
  
     function main(){
       canvas = document.createElement("canvas");
  
       //Set the width and height to the sizes of the browser
       width = window.innerWidth;
       height = window.innerHeight;
  
       //Frames the game if the width is larger than 500
       if(width >=500){
         width = 320;
         height = 480;
         canvas.style.border = "1px solid #000";
  
         var evt = "mousedown";
       }
  
  
  
       //Sets the canvas sizes to the width and height variables
       canvas.width = width;
       canvas.height = height;
       ctx = canvas.getContext("2d");
  
       //Set the default state
       // "states" is not defined so I'm commenting this out
       // var currentstate = states.Splash;
  
       document.body.appendChild(canvas);
  
       render();
    }
    
    main();
  
    function render(){
      //Adding bird
      bird.draw();
    }
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
nleoutsapro
0viewers