var LifeIndicator = Container.expand(function () {
var self = Container.call(this);
self.lives = 3;
self.indicators = [];
for (var i = 0; i < self.lives; i++) {
var lifeCar = self.createAsset('car', 'Life Indicator Car', 0.5, 0.5);
lifeCar.scale.set(0.5);
lifeCar.x = i * (lifeCar.width + 10);
self.indicators.push(lifeCar);
self.addChild(lifeCar);
}
self.updateLives = function (lives) {
self.lives = lives;
for (var i = 0; i < self.indicators.length; i++) {
self.indicators[i].visible = i < self.lives;
}
};
});
var Button = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.createAsset('button', 'Button Graphics', .5, .5);
});
var Lane = Container.expand(function () {
var self = Container.call(this);
var laneGraphics = self.createAsset('lane', 'Lane Graphics', 0, 0);
laneGraphics.height = 2732;
laneGraphics.width = 2;
laneGraphics.tint = 0xFFFFFF;
self.addChild(laneGraphics);
});
var Car = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.createAsset('car', 'Car Graphics', .5, .5);
carGraphics.tint = Math.random() * 0xFFFFFF;
while (carGraphics.tint < 0x0A0A0A) {
carGraphics.tint = Math.random() * 0xFFFFFF;
}
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.createAsset('player', 'Player Graphics', .5, .5);
self.lives = 3;
self.moveLeft = function (laneWidth) {
self.x = Math.max(laneWidth / 2, Math.floor((self.x - laneWidth) / laneWidth) * laneWidth + laneWidth / 2);
};
self.moveRight = function (laneWidth) {
self.x = Math.min(2048 - laneWidth / 2, Math.ceil((self.x + laneWidth) / laneWidth) * laneWidth - laneWidth / 2);
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var startTime = Date.now();
self.speedMultiplier = 1.0;
LK.stageContainer.setBackgroundColor(0x000000);
var player = self.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
var lifeIndicator = self.addChild(new LifeIndicator());
lifeIndicator.x = 2048 - 300;
lifeIndicator.y = 50;
var leftButton = self.addChild(new Button());
leftButton.x = 100;
leftButton.y = 2732 - 200;
var rightButton = self.addChild(new Button());
rightButton.x = 2048 - 100;
rightButton.y = 2732 - 200;
var carsPassedTxt = new Text2('0', {
size: 150,
fill: '#ffffff'
});
LK.gui.topLeft.addChild(carsPassedTxt);
var laneWidth = 2048 / 6;
for (var i = 1; i < 6; i++) {
var lane = new Lane();
lane.x = i * laneWidth;
self.addChild(lane);
}
var cars = [];
var carsPassed = 0;
LK.on('tick', function () {
if (LK.ticks % (60 * 5) === 0) {
self.speedMultiplier *= 1.1;
}
for (var a = cars.length - 1; a >= 0; a--) {
cars[a].move();
if (cars[a].y > 2732) {
cars[a].destroy();
cars.splice(a, 1);
carsPassed++;
}
}
var currentTime = Date.now();
var timeElapsed = (currentTime - startTime) / 1000;
var spawnRate = timeElapsed > 20 ? Math.pow(1.10, Math.floor((timeElapsed - 20) / 5)) : 1;
if (LK.ticks % Math.floor(60 / spawnRate) == 0) {
var newCar = new Car();
var laneWidth = 2048 / 6;
newCar.x = Math.floor(Math.random() * 6) * laneWidth + laneWidth / 2;
newCar.y = 0;
newCar.speed *= self.speedMultiplier;
cars.push(newCar);
self.addChild(newCar);
}
carsPassedTxt.setText(carsPassed);
for (var i = 0; i < cars.length; i++) {
if (player.intersects(cars[i])) {
player.lives--;
lifeIndicator.updateLives(player.lives);
if (player.lives <= 0) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
} else {
cars[i].destroy();
cars.splice(i, 1);
}
}
}
});
leftButton.on('down', function (obj) {
player.moveLeft(laneWidth);
});
rightButton.on('down', function (obj) {
player.moveRight(laneWidth);
});
});
generatr a image of a car with style like lambougini. we need to see the car from the top Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
generate a picture of a classic car. view from top. Vertical direction Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
generate a arcade like round button in red color Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
generate image single white dashed road edge marking line. vertical direction. exempted. no background. just simple line nothing else on pic Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.