User prompt
undo
User prompt
undu
User prompt
some time fall bum
User prompt
power up fall for unlimted time randamly
User prompt
delete green boxes
User prompt
power up img fall contnuasly
User prompt
every red boll acts same
User prompt
green boxes fall for infinite time
User prompt
add score
User prompt
remove score
User prompt
remove 0 backward from score
User prompt
remove 0 form behind the score
User prompt
score colour balack
User prompt
add a score option
User prompt
blue box cannot move autometcaly
User prompt
when green box tuch to blue box then increase score
User prompt
red fall to bootom
User prompt
blue box at a little upper foeom bottom
User prompt
all bolls fall down to bottom
User prompt
green boll also fall down
User prompt
blue box only sid move
User prompt
Please fix the bug: 'Uncaught TypeError: game.start is not a function' in or related to this line: 'game.start();' Line Number: 143
Code edit (1 edits merged)
Please save this source code
Initial prompt
Bike Race
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Define the Bike class var Bike = Container.expand(function () { var self = Container.call(this); var bikeGraphics = self.attachAsset('bike', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.acceleration = 0.2; self.maxSpeed = 10; self.update = function () { self.y -= self.speed; if (self.speed < self.maxSpeed) { self.speed += self.acceleration; } }; self.resetSpeed = function () { self.speed = 0; }; }); // Define the Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 5; if (self.y > 2732) { self.y = -100; self.x = Math.random() * 2048; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize game variables var bike = game.addChild(new Bike()); bike.x = 2048 / 2; bike.y = 2732 - 200; var obstacles = []; for (var i = 0; i < 5; i++) { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.y = Math.random() * -2732; obstacles.push(obstacle); game.addChild(obstacle); } var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var score = 0; var gameOver = false; function handleMove(x, y, obj) { if (!gameOver) { bike.x = x; } } game.move = handleMove; game.update = function () { if (!gameOver) { bike.update(); for (var i = 0; i < obstacles.length; i++) { obstacles[i].update(); if (bike.intersects(obstacles[i])) { gameOver = true; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } score += 1; scoreTxt.setText(score); } };
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Define the Bike class
var Bike = Container.expand(function () {
var self = Container.call(this);
var bikeGraphics = self.attachAsset('bike', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
self.acceleration = 0.2;
self.maxSpeed = 10;
self.update = function () {
self.y -= self.speed;
if (self.speed < self.maxSpeed) {
self.speed += self.acceleration;
}
};
self.resetSpeed = function () {
self.speed = 0;
};
});
// Define the Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += 5;
if (self.y > 2732) {
self.y = -100;
self.x = Math.random() * 2048;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize game variables
var bike = game.addChild(new Bike());
bike.x = 2048 / 2;
bike.y = 2732 - 200;
var obstacles = [];
for (var i = 0; i < 5; i++) {
var obstacle = new Obstacle();
obstacle.x = Math.random() * 2048;
obstacle.y = Math.random() * -2732;
obstacles.push(obstacle);
game.addChild(obstacle);
}
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var score = 0;
var gameOver = false;
function handleMove(x, y, obj) {
if (!gameOver) {
bike.x = x;
}
}
game.move = handleMove;
game.update = function () {
if (!gameOver) {
bike.update();
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].update();
if (bike.intersects(obstacles[i])) {
gameOver = true;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
score += 1;
scoreTxt.setText(score);
}
};