Proviamo...
<!DOCTYPE html>
<html>
<head>
<script>
function Game(){
this.div=document.getElementById("GameDiv");
this.div.style.width="768";
this.div.style.height="512";
this.canvas=document.getElementById("GameCanvas");
this.canvas.setAttribute("width","768");
this.canvas.setAttribute("height","512");
this.canvas.defaultWidth=this.canvas.width;
this.canvas.defaultHeight=this.canvas.height;
this.canvas.style.cursor="none";
this.ctx=this.canvas.getContext("2d");
this.GameLoop=function(){
if(!this.paused){
this.Update();
}
this.Draw();
window.requestAnimFrame(function(){
game.GameLoop();
});
}
}
function StartGame(){
game=new Game();
}
window.addEventListener("load",function(){
StartGame();
},true);
</script>
</head>
<body>
<div id="GameDiv">
<canvas id="GameCanvas">
</canvas>
</div>
</body>
</html>
Però ora il tutorial mi fa una divagazione sull'ereditarietà prototipale del Javascript...Conviene seguirla...
Nessun commento:
Posta un commento