/**** * Classes ****/ var Barrel = Container.expand(function () { var self = Container.call(this); var barrelGraphics = self.attachAsset('barrel', { anchorX: 0.5, anchorY: 0.5 }); barrelGraphics.tint = Math.random() * 0xFFFFFF; while (barrelGraphics.tint < 0x0A0A0A) { barrelGraphics.tint = Math.random() * 0xFFFFFF; } self.speed = 5; self._move_migrated = function () { self.y += self.speed; }; }); var Button = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); }); var Lane = Container.expand(function () { var self = Container.call(this); var laneGraphics = self.attachAsset('lane', {}); laneGraphics.height = 2732; laneGraphics.width = 2; laneGraphics.tint = 0xFFFFFF; self.addChild(laneGraphics); }); var LifeIndicator = Container.expand(function () { var self = Container.call(this); self.lives = 3; self.indicators = []; for (var i = 0; i < self.lives; i++) { var lifeBarrel = self.attachAsset('barrel', { anchorX: 0.5, anchorY: 0.5 }); lifeBarrel.scale.set(0.5); lifeBarrel.x = i * (lifeBarrel.width + 10); self.indicators.push(lifeBarrel); self.addChild(lifeBarrel); } self.updateLives = function (lives) { self.lives = lives; for (var i = 0; i < self.indicators.length; i++) { self.indicators[i].visible = i < self.lives; } }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.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); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var startTime = Date.now(); game.speedMultiplier = 1.0; game.setBackgroundColor(0x000000); var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 200; var lifeIndicator = game.addChild(new LifeIndicator()); lifeIndicator.x = 2048 - 300; lifeIndicator.y = 50; var leftButton = game.addChild(new Button()); leftButton.x = 100; leftButton.y = 2732 - 200; var rightButton = game.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; game.addChild(lane); } var barrels = []; var carsPassed = 0; LK.on('tick', function () { if (LK.ticks % (60 * 5) === 0) { game.speedMultiplier *= 1.1; } for (var a = barrels.length - 1; a >= 0; a--) { barrels[a]._move_migrated(); if (barrels[a].y > 2732) { barrels[a].destroy(); barrels.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 newBarrel = new Barrel(); var laneWidth = 2048 / 6; newBarrel.x = Math.floor(Math.random() * 6) * laneWidth + laneWidth / 2; newBarrel.y = 0; newBarrel.speed *= game.speedMultiplier; barrels.push(newBarrel); game.addChild(newBarrel); } carsPassedTxt.setText(carsPassed); for (var i = 0; i < barrels.length; i++) { if (player.intersects(barrels[i])) { player.lives--; lifeIndicator.updateLives(player.lives); if (player.lives <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else { barrels[i].destroy(); barrels.splice(i, 1); } } } }); leftButton.on('down', function (x, y, obj) { player.moveLeft(laneWidth); }); rightButton.on('down', function (x, y, obj) { player.moveRight(laneWidth); });
/****
* Classes
****/
var Barrel = Container.expand(function () {
var self = Container.call(this);
var barrelGraphics = self.attachAsset('barrel', {
anchorX: 0.5,
anchorY: 0.5
});
barrelGraphics.tint = Math.random() * 0xFFFFFF;
while (barrelGraphics.tint < 0x0A0A0A) {
barrelGraphics.tint = Math.random() * 0xFFFFFF;
}
self.speed = 5;
self._move_migrated = function () {
self.y += self.speed;
};
});
var Button = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Lane = Container.expand(function () {
var self = Container.call(this);
var laneGraphics = self.attachAsset('lane', {});
laneGraphics.height = 2732;
laneGraphics.width = 2;
laneGraphics.tint = 0xFFFFFF;
self.addChild(laneGraphics);
});
var LifeIndicator = Container.expand(function () {
var self = Container.call(this);
self.lives = 3;
self.indicators = [];
for (var i = 0; i < self.lives; i++) {
var lifeBarrel = self.attachAsset('barrel', {
anchorX: 0.5,
anchorY: 0.5
});
lifeBarrel.scale.set(0.5);
lifeBarrel.x = i * (lifeBarrel.width + 10);
self.indicators.push(lifeBarrel);
self.addChild(lifeBarrel);
}
self.updateLives = function (lives) {
self.lives = lives;
for (var i = 0; i < self.indicators.length; i++) {
self.indicators[i].visible = i < self.lives;
}
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.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);
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var startTime = Date.now();
game.speedMultiplier = 1.0;
game.setBackgroundColor(0x000000);
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
var lifeIndicator = game.addChild(new LifeIndicator());
lifeIndicator.x = 2048 - 300;
lifeIndicator.y = 50;
var leftButton = game.addChild(new Button());
leftButton.x = 100;
leftButton.y = 2732 - 200;
var rightButton = game.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;
game.addChild(lane);
}
var barrels = [];
var carsPassed = 0;
LK.on('tick', function () {
if (LK.ticks % (60 * 5) === 0) {
game.speedMultiplier *= 1.1;
}
for (var a = barrels.length - 1; a >= 0; a--) {
barrels[a]._move_migrated();
if (barrels[a].y > 2732) {
barrels[a].destroy();
barrels.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 newBarrel = new Barrel();
var laneWidth = 2048 / 6;
newBarrel.x = Math.floor(Math.random() * 6) * laneWidth + laneWidth / 2;
newBarrel.y = 0;
newBarrel.speed *= game.speedMultiplier;
barrels.push(newBarrel);
game.addChild(newBarrel);
}
carsPassedTxt.setText(carsPassed);
for (var i = 0; i < barrels.length; i++) {
if (player.intersects(barrels[i])) {
player.lives--;
lifeIndicator.updateLives(player.lives);
if (player.lives <= 0) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
} else {
barrels[i].destroy();
barrels.splice(i, 1);
}
}
}
});
leftButton.on('down', function (x, y, obj) {
player.moveLeft(laneWidth);
});
rightButton.on('down', function (x, y, obj) {
player.moveRight(laneWidth);
});
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.
Super Mario. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Barrel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.