User prompt
Do not show a car above the track
User prompt
Show car above the track like coins
User prompt
Show a celebration after every 100 points
User prompt
Show a starting message in start of game saying " Collect all treasures "
User prompt
Add collecting coins also in game to gain more points
Initial prompt
Beast racing
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Car class representing the player's car
var Car = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
self.maxSpeed = 10;
self.acceleration = 0.2;
self.deceleration = 0.1;
self.update = function () {
self.y -= self.speed;
if (self.speed > 0) {
self.speed -= self.deceleration;
}
};
});
// Obstacle class representing obstacles on the track
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; // Move obstacle downwards
};
});
// Track class representing the racing track
var Track = Container.expand(function () {
var self = Container.call(this);
var trackGraphics = self.attachAsset('track', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Logic for moving the track to simulate car movement
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize game elements
var playerCar = game.addChild(new Car());
playerCar.x = 2048 / 2;
playerCar.y = 2732 - 200;
var track = game.addChild(new Track());
track.x = 2048 / 2;
track.y = 2732 / 2;
var obstacles = [];
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to handle car movement
function handleMove(x, y, obj) {
playerCar.x = x;
}
// Function to update game state
game.update = function () {
playerCar.update();
track.update();
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].update();
if (obstacles[i].y > 2732) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
if (playerCar.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Spawn new obstacles
if (LK.ticks % 60 == 0) {
var newObstacle = new Obstacle();
newObstacle.x = Math.random() * 2048;
newObstacle.y = -50;
obstacles.push(newObstacle);
game.addChild(newObstacle);
}
// Update score
score += 1;
scoreTxt.setText(score);
};
// Event listeners for touch controls
game.down = function (x, y, obj) {
handleMove(x, y, obj);
};
game.move = function (x, y, obj) {
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
// Stop car acceleration
playerCar.speed = 0;
};
A sports car from top view (2d). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A stone from top view (2d). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A chest for 2d game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.