<!DOCTYPE = html> <html><body> <canvas id="myCanvas" width="640" height="480" style="border:1px solid #d3d3d3;"> Use different browser. </canvas> <script> var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); var enemy = { x:10, y:10, w:32, h:32, color:'red', }; var player = { x:100, y:100, w:32, h:32, color:'blue', }; drawentity(player); drawentity(enemy); function drawentity(entity){ ctx.fillStyle=entity.color; ctx.fillRect(entity.x,entity.y,entity.w,entity.h); } </script></body></html>
No comments:
Post a Comment