/**** * Classes ****/ var Background = Container.expand(function () { var self = Container.call(this); var backgroundGraphics = self.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); }); var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.y += self.speed; }; }); var Basket = Container.expand(function () { var self = Container.call(this); var basketGraphics = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5 }); }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background = game.addChild(new Background()); LK.playMusic('backgroundMusic'); background.x = 2048 / 2; background.y = 2732 / 2; var basket = game.addChild(new Basket()); basket.x = 2048 / 2; basket.y = 2732 - 100; var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var balls = []; var obstacles = []; game.update = function () { if (LK.ticks % 30 == 0) { var newBall = new Ball(); newBall.x = Math.random() * 2048; newBall.y = 0; balls.push(newBall); game.addChild(newBall); } if (LK.ticks % 120 == 0) { var newObstacle = new Obstacle(); newObstacle.x = Math.random() * 2048; newObstacle.y = 0; obstacles.push(newObstacle); game.addChild(newObstacle); } for (var i = balls.length - 1; i >= 0; i--) { if (balls[i].intersects(basket)) { LK.setScore(LK.getScore() + 1); balls[i].destroy(); balls.splice(i, 1); scoreTxt.setText(LK.getScore()); LK.getSound('ballCollision').play(); } } for (var i = obstacles.length - 1; i >= 0; i--) { if (obstacles[i].intersects(basket)) { LK.showGameOver(); } } }; game.move = function (x, y, obj) { basket.x = x; };
/****
* Classes
****/
var Background = Container.expand(function () {
var self = Container.call(this);
var backgroundGraphics = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
self.y += self.speed;
};
});
var Basket = Container.expand(function () {
var self = Container.call(this);
var basketGraphics = self.attachAsset('basket', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
self.y += self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var background = game.addChild(new Background());
LK.playMusic('backgroundMusic');
background.x = 2048 / 2;
background.y = 2732 / 2;
var basket = game.addChild(new Basket());
basket.x = 2048 / 2;
basket.y = 2732 - 100;
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var balls = [];
var obstacles = [];
game.update = function () {
if (LK.ticks % 30 == 0) {
var newBall = new Ball();
newBall.x = Math.random() * 2048;
newBall.y = 0;
balls.push(newBall);
game.addChild(newBall);
}
if (LK.ticks % 120 == 0) {
var newObstacle = new Obstacle();
newObstacle.x = Math.random() * 2048;
newObstacle.y = 0;
obstacles.push(newObstacle);
game.addChild(newObstacle);
}
for (var i = balls.length - 1; i >= 0; i--) {
if (balls[i].intersects(basket)) {
LK.setScore(LK.getScore() + 1);
balls[i].destroy();
balls.splice(i, 1);
scoreTxt.setText(LK.getScore());
LK.getSound('ballCollision').play();
}
}
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i].intersects(basket)) {
LK.showGameOver();
}
}
};
game.move = function (x, y, obj) {
basket.x = x;
};
rock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A sunset beach background with waves and palm trees.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a robotic basket with high contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
robotic and shiny balls. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows