Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: x0000FF is not defined' in or related to this line: 'var game = new LK.Game({' Line Number: 57
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: x000000 is not defined' in or related to this line: 'var game = new LK.Game({' Line Number: 57
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: x00000 is not defined' in or related to this line: 'var game = new LK.Game({' Line Number: 56
Code edit (1 edits merged)
Please save this source code
Initial prompt
Flaping bird
/**** * Classes ****/ // Assets will be automatically created and loaded during gameplay // Bird class var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.speedY = 2; self.gravity = 1; self.flapStrength = -30; self.update = function () { self.speedY += self.gravity; self.y += self.speedY; if (self.y > 2732 - birdGraphics.height / 2) { self.y = 2732 - birdGraphics.height / 2; self.speedY = 0; } if (self.y < birdGraphics.height / 2) { self.y = birdGraphics.height / 2; self.speedY = 0; } }; self.flap = function () { self.speedY = self.flapStrength; }; }); // Wall class var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = -5; self.update = function () { self.x += self.speedX; if (self.x < -wallGraphics.width / 2) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: x0000FF //Init game with black background }); /**** * Game Code ****/ var bird = game.addChild(new Bird()); bird.x = 2048 / 2; bird.y = 2732 / 2; var walls = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); function createWall() { var wall = new Wall(); wall.x = 2048 + wall.width / 2; wall.y = Math.random() * (2732 - wall.height) + wall.height / 2; walls.push(wall); game.addChild(wall); } function handleMove(x, y, obj) { // No-op for now } game.down = function (x, y, obj) { bird.flap(); }; game.update = function () { bird.update(); for (var i = walls.length - 1; i >= 0; i--) { walls[i].update(); if (bird.intersects(walls[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } if (LK.ticks % 60 == 0) { createWall(); } scoreTxt.setText(score); };
===================================================================
--- original.js
+++ change.js
@@ -47,9 +47,9 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000
+ backgroundColor: x0000FF
//Init game with black background
});
/****