Games

function startGame() { var myGamePiece = new component(30, 30, "red", 10, 120); myGamePiece.gravity = 0.05; var myScore = new component("30px", "Consolas", "black", 280, 40, "text"); var myGameArea = { canvas : document.createElement("canvas"), start : function() { this.canvas.width = 480; this.canvas.height = 270; this.context = this.canvas.getContext("2d")
; document.body.insertBefore(this.canvas, document.body.childNodes[0]); this.frameNo = 0; }, clear : function() { this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); } }; myGameArea.start(); } function component(width, height, color, x, y, type) { this.type = type; if (type == "text") { this.text = color; } this.width = width; this.height = height; this.speedX = 0; this.speedY = 0; this.x = x; this.y = y; this.gravity = 0; this.gravitySpeed = 0; this.update = function() { ctx = myGameArea.context; if (type == "text") { ctx.font = this.width + " " + this.height; ctx.fillStyle = color; ctx.fillText(this.text, this.x, this.y); } else { ctx.fillStyle = color; ctx.fillRect(this.x, this.y, this.width, this.height); } } } Founder&C.E.O of #AtoZ_SnS @a2zservicesandsolutions Digital Creator A Degree in Engineering & Enterpreneurship अधिक जानकारी के लिए गूगल पर सर्च करें।

टिप्पणियाँ