<!DOCTYPE html> <html> <head> <script> <!DOCTYPE html> <html> <head> <script> </script> </head> <body> <div id="GameDiv"> <canvas id="GameCanvas"> </canvas> </div> </body> </html>>
Ora scriviamo la funzione Game() in Javascript.
<!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");
}
function StartGame(){
game=new Game();
}
window.addEventListener("load",function(){
StartGame();
},true);
</script>
</head>
<body>
<div id="GameDiv">
<canvas id="GameCanvas">
</canvas>
</div>
</body>
</html>
Ecco.
Nessun commento:
Posta un commento