User prompt
more score more cars and buses spawn
User prompt
when car touch the bus car this car start to move with the bus speed
User prompt
bus and cars can't move throw each other
User prompt
player starts on second line
User prompt
plaeyr and other cars move on same lines
User prompt
add interface player has 3 lives
User prompt
add player has 3 lives, make the collision and player can move from line to line
User prompt
make player move from on line to another
User prompt
add interfase with 3 lives
User prompt
make collision
User prompt
make scins to the cars and lines and move buttons
Initial prompt
Megarace
/**** * Classes ****/ // Bus class var Bus = Container.expand(function () { var self = Container.call(this); var busGraphics = self.attachAsset('bus', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // Assets will be automatically created and loaded during gameplay // Car class var Car = Container.expand(function () { var self = Container.call(this); var carGraphics = self.attachAsset('car', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.lane = 2; self.lives = 3; self.moveLeft = function () { if (self.lane > 1) { self.lane--; self.x = self.lane * 512 - 256; } }; self.moveRight = function () { if (self.lane < 4) { self.lane++; self.x = self.lane * 512 - 256; } }; self.loseLife = function () { self.lives--; livesTxt.setText('Lives: ' + self.lives); if (self.lives <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ var player = game.addChild(new Player()); player.x = 1024; player.y = 2400; var cars = []; var buses = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var livesTxt = new Text2('Lives: 3', { size: 100, fill: "#ffffff" }); livesTxt.anchor.set(0.5, 0); LK.gui.topRight.addChild(livesTxt); function spawnVehicle() { var lane = Math.floor(Math.random() * 4) + 1; var vehicle; if (Math.random() < 0.5) { vehicle = new Car(); cars.push(vehicle); } else { vehicle = new Bus(); buses.push(vehicle); } vehicle.x = lane * 512 - 256; vehicle.y = -100; game.addChild(vehicle); } game.down = function (x, y, obj) { if (x < 1024) { player.moveLeft(); } else { player.moveRight(); } }; game.update = function () { for (var i = cars.length - 1; i >= 0; i--) { if (cars[i].intersects(player)) { player.loseLife(); } cars[i].update(); } for (var j = buses.length - 1; j >= 0; j--) { if (buses[j].intersects(player)) { player.loseLife(); } buses[j].update(); } if (LK.ticks % 60 == 0) { spawnVehicle(); score++; scoreTxt.setText(score); } };
===================================================================
--- original.js
+++ change.js
@@ -43,15 +43,15 @@
self.lives = 3;
self.moveLeft = function () {
if (self.lane > 1) {
self.lane--;
- self.x -= 512;
+ self.x = self.lane * 512 - 256;
}
};
self.moveRight = function () {
if (self.lane < 4) {
self.lane++;
- self.x += 512;
+ self.x = self.lane * 512 - 256;
}
};
self.loseLife = function () {
self.lives--;
delete white line
four-lane road on full image. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
left turn signal of the car. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round car steering wheel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.