Code edit (1 edits merged)
Please save this source code
User prompt
create an asset called bullet and set spawn from the bike horizontally on the game
User prompt
remove bullet logic
User prompt
remove bullet asset
User prompt
remove make the bike asset to shoot every 5 seconds
Code edit (1 edits merged)
Please save this source code
User prompt
make the bike asset to shoot every 5 seconds
User prompt
attach the bullet to the bike
User prompt
make the bullet comes from the bike
User prompt
make the bike able to shoot
Code edit (1 edits merged)
Please save this source code
User prompt
spawn the obstacle3 asset in the game don't replace the obstacle2 and bike
User prompt
spawn the obstacle3 asset in the game
Code edit (3 edits merged)
Please save this source code
User prompt
create another asset and only assign the same logic as obstacle , not obstacle2 and name it as obstacle3
User prompt
remove obstacle3 and its logic
User prompt
remove obstacle3 and assign the same logic as obstacle2
User prompt
create another asset and assign the same logic as obstacle and name it as obstacle3
User prompt
adjust the postion of the obstacle2 spawn always towards the player
User prompt
Please fix the bug: 'ReferenceError: obstacle2 is not defined' in or related to this line: 'if (bike.intersects(obstacle2)) {' Line Number: 107
User prompt
add a collison between bike and obstacle2 if obstacle2 hit the player make it as game over
User prompt
add a default downward movement for obstacle2
Code edit (1 edits merged)
Please save this source code
User prompt
make obstacle2 falling from the top of the screen
User prompt
remove randomize the vertical spawn position for obstacle2
/**** * Classes ****/ var Bike = Container.expand(function () { var self = Container.call(this); var bikeGraphics = self.attachAsset('bike', { anchorX: 0, anchorY: -2.5, scaleX: 3, scaleY: 3 }); self.update = function () { self.x += 0.5; if (self.x > 2048) { self.x = -100; } }; self.jumping = false; self.jumpCounter = 0; self.shootCounter = 0; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0, anchorY: -2.5, scaleX: 2, scaleY: 2 }); self.update = function () { self.x += 10; }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: -3, anchorY: -2.3, scaleX: 3, scaleY: 3 }); self.update = function () { self.x -= 10; }; }); var Obstacle2 = Container.expand(function () { var self = Container.call(this); var obstacle2Graphics = self.attachAsset('obstacle2', { anchorX: -3, anchorY: 2.3, scaleX: 2, scaleY: 2 }); self.update = function () { self.x -= 10; self.y += 5; // Add a default downward movement for obstacle2 }; }); var Road = Container.expand(function () { var self = Container.call(this); var roadGraphics = self.attachAsset('road', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var road = game.addChild(new Road()); road.x = 2048 / 2; road.y = 2732 / 2; var background1 = road; var background2 = new Road(); game.addChild(background2); background2.x = background1.x + 2048; background2.y = 2732 / 2; // Position background2 at the center of the screen vertically var bike = game.addChild(new Bike()); var obstacle = game.addChild(new Obstacle()); obstacle.x = 2048 / 2; obstacle.y = 2732 / 2; bike.x = 0; bike.y = 2732 / 2; var obstacle2; // Define obstacle2 in the global scope game.update = function () { background1.x -= 5; background2.x -= 5; if (background1.x <= -1024) { background1.x = background2.x + 2048; } if (background2.x <= -1024) { background2.x = background1.x + 2048; } if (LK.ticks % Math.floor(Math.random() * 1800) == 0) { // 60 ticks per second, so 1800 ticks = 30 seconds var newObstacle = new Obstacle(); newObstacle.x = 2048; // spawn at the right edge of the screen newObstacle.y = 2732 / 2; // spawn at the middle of the screen vertically game.addChild(newObstacle); obstacle2 = new Obstacle2(); // Assign the new Obstacle2 instance to the global obstacle2 variable obstacle2.x = 2048; // spawn at the right edge of the screen obstacle2.y = bike.y; // spawn at the player's vertical position game.addChild(obstacle2); } // Check if bike collides with obstacle2 if (bike.intersects(obstacle2)) { // Show game over. The game will be automatically paused while game over is showing. LK.showGameOver(); // Calling this will destroy the 'Game' and reset entire game state. } if (bike.jumping) { bike.y -= 50; bike.jumpCounter++; if (bike.jumpCounter > 20) { bike.jumping = false; } bike.shootCounter++; if (bike.shootCounter >= 300) { // 60 ticks per second, so 300 ticks = 5 seconds var bullet = new Bullet(); bullet.x = bike.x; bullet.y = bike.y; game.addChild(bullet); bike.shootCounter = 0; } } else if (bike.y < 2732 / 2) { bike.y += 15; } else { bike.jumpCounter = 0; } }; game.down = function (x, y, obj) { if (!bike.jumping) { bike.jumping = true; } };
===================================================================
--- original.js
+++ change.js
@@ -21,12 +21,12 @@
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.5,
- scaleY: 0.5
+ anchorX: 0,
+ anchorY: -2.5,
+ scaleX: 2,
+ scaleY: 2
});
self.update = function () {
self.x += 10;
};
sci fi bike with person riding facing right side Single Game Texture. In-Game asset. High contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
sci fi bike with person riding facing right side Single Game Texture. In-Game asset. High contrast.
asteroid falling diffrent colors Single Game Texture. In-Game asset. High contrast. No Background