User prompt
add left and right move button in the right and left side if end of screen
User prompt
add background song from my b4 song
User prompt
add button was not added
User prompt
please add a shop option on right side of top of screen
User prompt
add a shop option in the right side of the top of screen
User prompt
please add a point table on the top of screen
User prompt
also increase the 2x size of obstacle car
User prompt
increase the 2x size of all cars
User prompt
when player collects 30 coin game was ended
User prompt
just a small up my car
User prompt
down my car
User prompt
can you move my car at up side of screen
User prompt
add a highway background
Initial prompt
go for ride
/**** * Classes ****/ // Class for coins var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 5; // Move coins downwards }; }); // Class for obstacles 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 += 7; // Move obstacles downwards }; }); //<Assets used in the game will automatically appear here> // Class for the player's vehicle var PlayerVehicle = Container.expand(function () { var self = Container.call(this); var vehicleGraphics = self.attachAsset('playerVehicle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Update logic for player vehicle }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Add a highway background var background = LK.getAsset('backgroundColumn', { anchorX: 0.5, anchorY: 0.5, scaleX: 20.48, // Scale to fit the width of the game scaleY: 27.32 // Scale to fit the height of the game }); background.x = 2048 / 2; background.y = 2732 / 2; game.addChild(background); // Initialize arrays for coins and obstacles var coins = []; var obstacles = []; var playerVehicle = game.addChild(new PlayerVehicle()); playerVehicle.x = 2048 / 2; playerVehicle.y = 2732 - 200; // Function to handle movement function handleMove(x, y, obj) { playerVehicle.x = x; } // Event listeners for touch/mouse events game.down = function (x, y, obj) { handleMove(x, y, obj); }; game.move = function (x, y, obj) { handleMove(x, y, obj); }; // Game update loop game.update = function () { // Update player vehicle playerVehicle.update(); // Update coins for (var i = coins.length - 1; i >= 0; i--) { coins[i].update(); if (coins[i].intersects(playerVehicle)) { // Collect coin coins[i].destroy(); coins.splice(i, 1); LK.setScore(LK.getScore() + 1); } else if (coins[i].y > 2732) { // Remove off-screen coins coins[i].destroy(); coins.splice(i, 1); } } // Update obstacles for (var j = obstacles.length - 1; j >= 0; j--) { obstacles[j].update(); if (obstacles[j].intersects(playerVehicle)) { // Collision with obstacle LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else if (obstacles[j].y > 2732) { // Remove off-screen obstacles obstacles[j].destroy(); obstacles.splice(j, 1); } } // Spawn new coins and obstacles if (LK.ticks % 60 == 0) { var newCoin = new Coin(); newCoin.x = Math.random() * 2048; newCoin.y = -50; coins.push(newCoin); game.addChild(newCoin); var newObstacle = new Obstacle(); newObstacle.x = Math.random() * 2048; newObstacle.y = -50; obstacles.push(newObstacle); game.addChild(newObstacle); } };
===================================================================
--- original.js
+++ change.js
@@ -1,111 +1,122 @@
-/****
+/****
* Classes
-****/
+****/
// Class for coins
var Coin = Container.expand(function () {
- var self = Container.call(this);
- var coinGraphics = self.attachAsset('coin', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- self.y += 5; // Move coins downwards
- };
+ var self = Container.call(this);
+ var coinGraphics = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ self.y += 5; // Move coins downwards
+ };
});
// Class for obstacles
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 += 7; // Move obstacles downwards
- };
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ self.y += 7; // Move obstacles downwards
+ };
});
//<Assets used in the game will automatically appear here>
// Class for the player's vehicle
var PlayerVehicle = Container.expand(function () {
- var self = Container.call(this);
- var vehicleGraphics = self.attachAsset('playerVehicle', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 10;
- self.update = function () {
- // Update logic for player vehicle
- };
+ var self = Container.call(this);
+ var vehicleGraphics = self.attachAsset('playerVehicle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 10;
+ self.update = function () {
+ // Update logic for player vehicle
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
+// Add a highway background
+var background = LK.getAsset('backgroundColumn', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 20.48,
+ // Scale to fit the width of the game
+ scaleY: 27.32 // Scale to fit the height of the game
+});
+background.x = 2048 / 2;
+background.y = 2732 / 2;
+game.addChild(background);
// Initialize arrays for coins and obstacles
var coins = [];
var obstacles = [];
var playerVehicle = game.addChild(new PlayerVehicle());
playerVehicle.x = 2048 / 2;
playerVehicle.y = 2732 - 200;
// Function to handle movement
function handleMove(x, y, obj) {
- playerVehicle.x = x;
+ playerVehicle.x = x;
}
// Event listeners for touch/mouse events
game.down = function (x, y, obj) {
- handleMove(x, y, obj);
+ handleMove(x, y, obj);
};
game.move = function (x, y, obj) {
- handleMove(x, y, obj);
+ handleMove(x, y, obj);
};
// Game update loop
game.update = function () {
- // Update player vehicle
- playerVehicle.update();
- // Update coins
- for (var i = coins.length - 1; i >= 0; i--) {
- coins[i].update();
- if (coins[i].intersects(playerVehicle)) {
- // Collect coin
- coins[i].destroy();
- coins.splice(i, 1);
- LK.setScore(LK.getScore() + 1);
- } else if (coins[i].y > 2732) {
- // Remove off-screen coins
- coins[i].destroy();
- coins.splice(i, 1);
- }
- }
- // Update obstacles
- for (var j = obstacles.length - 1; j >= 0; j--) {
- obstacles[j].update();
- if (obstacles[j].intersects(playerVehicle)) {
- // Collision with obstacle
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- } else if (obstacles[j].y > 2732) {
- // Remove off-screen obstacles
- obstacles[j].destroy();
- obstacles.splice(j, 1);
- }
- }
- // Spawn new coins and obstacles
- if (LK.ticks % 60 == 0) {
- var newCoin = new Coin();
- newCoin.x = Math.random() * 2048;
- newCoin.y = -50;
- coins.push(newCoin);
- game.addChild(newCoin);
- var newObstacle = new Obstacle();
- newObstacle.x = Math.random() * 2048;
- newObstacle.y = -50;
- obstacles.push(newObstacle);
- game.addChild(newObstacle);
- }
+ // Update player vehicle
+ playerVehicle.update();
+ // Update coins
+ for (var i = coins.length - 1; i >= 0; i--) {
+ coins[i].update();
+ if (coins[i].intersects(playerVehicle)) {
+ // Collect coin
+ coins[i].destroy();
+ coins.splice(i, 1);
+ LK.setScore(LK.getScore() + 1);
+ } else if (coins[i].y > 2732) {
+ // Remove off-screen coins
+ coins[i].destroy();
+ coins.splice(i, 1);
+ }
+ }
+ // Update obstacles
+ for (var j = obstacles.length - 1; j >= 0; j--) {
+ obstacles[j].update();
+ if (obstacles[j].intersects(playerVehicle)) {
+ // Collision with obstacle
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ } else if (obstacles[j].y > 2732) {
+ // Remove off-screen obstacles
+ obstacles[j].destroy();
+ obstacles.splice(j, 1);
+ }
+ }
+ // Spawn new coins and obstacles
+ if (LK.ticks % 60 == 0) {
+ var newCoin = new Coin();
+ newCoin.x = Math.random() * 2048;
+ newCoin.y = -50;
+ coins.push(newCoin);
+ game.addChild(newCoin);
+ var newObstacle = new Obstacle();
+ newObstacle.x = Math.random() * 2048;
+ newObstacle.y = -50;
+ obstacles.push(newObstacle);
+ game.addChild(newObstacle);
+ }
};
\ No newline at end of file
highway. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
coin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
thar car. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
car. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.