<html>
<head>
<title>game</title>
<script>
window.onload = function(){
/*
var canvas = document.getElementById("canvas");
//alert(canvas);
var context = canvas.getContext("2d");
//alert(context);
var img = new Image;
alert(img);
img.src = "load_bar.png";
alert("img.src--"+img.src);
context.drawImage(img,50,60);
*/
var game = new Game();
game.init();
document.body.addEventListener("mousedown",function(){
//alert("mousedown");
game.move();
});
}
var image_x =60,image_y = 50;
//alert(image_y+""+image_x);
var img = new Image;
img.src = "load_bar.png";
var canvas,context;
function Game(){
//alert("game");
this.init = function(){
//alert("Game.init");
canvas = document.getElementById("canvas");
//alert(canvas);
context = canvas.getContext("2d");
//alert(context);
//alert(img);
//alert("img.src--"+img.src);
context.drawImage(img,image_x,image_y);
}
this.move = function(){
//image_x -=1;
//alert("move");
/*
if(image_y<180){
context.clearRect(0,0,400,500);
image_y = image_y +10;
//alert(image_y);
}else{
image_y = 50;
}
*/
for(var i = 0;i<200;i++){
//image_y = image_y +1;
a+lert(i);
context.clearRect(0,0,400,500);
image_y = image_y +1;
game.init();
//alert(image_y);
}
image_y = 50;
//image_y = 50;
}
}
var game = new Game();
setInterval(function(){
//alert("setInterval");
//game.init();
//game.move();
//alert(game);
},1E3);
</script>
</head>
<body>
<canvas id = "canvas" width = "400px" height = "500px" style = "border:1px solid red"></canvas>
</body>
</html>
<head>
<title>game</title>
<script>
window.onload = function(){
/*
var canvas = document.getElementById("canvas");
//alert(canvas);
var context = canvas.getContext("2d");
//alert(context);
var img = new Image;
alert(img);
img.src = "load_bar.png";
alert("img.src--"+img.src);
context.drawImage(img,50,60);
*/
var game = new Game();
game.init();
document.body.addEventListener("mousedown",function(){
//alert("mousedown");
game.move();
});
}
var image_x =60,image_y = 50;
//alert(image_y+""+image_x);
var img = new Image;
img.src = "load_bar.png";
var canvas,context;
function Game(){
//alert("game");
this.init = function(){
//alert("Game.init");
canvas = document.getElementById("canvas");
//alert(canvas);
context = canvas.getContext("2d");
//alert(context);
//alert(img);
//alert("img.src--"+img.src);
context.drawImage(img,image_x,image_y);
}
this.move = function(){
//image_x -=1;
//alert("move");
/*
if(image_y<180){
context.clearRect(0,0,400,500);
image_y = image_y +10;
//alert(image_y);
}else{
image_y = 50;
}
*/
for(var i = 0;i<200;i++){
//image_y = image_y +1;
a+lert(i);
context.clearRect(0,0,400,500);
image_y = image_y +1;
game.init();
//alert(image_y);
}
image_y = 50;
//image_y = 50;
}
}
var game = new Game();
setInterval(function(){
//alert("setInterval");
//game.init();
//game.move();
//alert(game);
},1E3);
</script>
</head>
<body>
<canvas id = "canvas" width = "400px" height = "500px" style = "border:1px solid red"></canvas>
</body>
</html>