User prompt
adjust the road movement speed with a variable
User prompt
adjust the road movement speed with a variable
Code edit (2 edits merged)
Please save this source code
User prompt
display the score on the game over UI on the screen
User prompt
display the score on the game over screen
Code edit (7 edits merged)
Please save this source code
User prompt
display the scoreboard on the screen
User prompt
Create a scoreboard based on bike distance
Code edit (7 edits merged)
Please save this source code
User prompt
dont attach bullet to bike
Code edit (1 edits merged)
Please save this source code
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
/**** * 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; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); self.speed = 10; self.update = function () { self.x += self.speed; }; }); 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 var bullets = []; // Array to keep track of bullets 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) { var newObstacle = new Obstacle(); newObstacle.x = 2048; newObstacle.y = 2732 / 2; game.addChild(newObstacle); obstacle2 = new Obstacle2(); obstacle2.x = 2048; obstacle2.y = bike.y; game.addChild(obstacle2); } for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; if (bullet.x > 2048) { game.removeChild(bullet); bullets.splice(i, 1); } else if (bullet.intersects(obstacle2)) { game.removeChild(bullet); bullets.splice(i, 1); game.removeChild(obstacle2); obstacle2 = null; } } if (bike.intersects(obstacle2)) { LK.showGameOver(); } if (bike.jumping) { bike.y -= 50; bike.jumpCounter++; if (bike.jumpCounter > 20) { bike.jumping = false; } } 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; } var bullet = new Bullet(); bullet.x = bike.x + bike.width; // Adjust the bullet's initial x position to come from the bike bullet.y = bike.y + bike.height / 2; // Adjust the bullet's initial y position to come from the middle of the bike game.addChild(bullet); bullets.push(bullet); };
===================================================================
--- original.js
+++ change.js
@@ -140,9 +140,9 @@
if (!bike.jumping) {
bike.jumping = true;
}
var bullet = new Bullet();
- bullet.x = bike.x;
- bullet.y = bike.y;
+ bullet.x = bike.x + bike.width; // Adjust the bullet's initial x position to come from the bike
+ bullet.y = bike.y + bike.height / 2; // Adjust the bullet's initial y position to come from the middle of the bike
game.addChild(bullet);
bullets.push(bullet);
};
\ No newline at end of file
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