/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Ball class
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 5;
self.speedY = 5;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
if (self.x <= 0 || self.x >= 2048) {
self.speedX *= -1;
}
if (self.y <= 0 || self.y >= 2732) {
self.speedY *= -1;
}
};
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Player update logic
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
var player1 = game.addChild(new Player());
player1.x = 1024;
player1.y = 2500;
var player2 = game.addChild(new Player());
player2.x = 1024;
player2.y = 200;
var ball = game.addChild(new Ball());
ball.x = 1024;
ball.y = 1366;
var score1 = 0;
var score2 = 0;
var scoreTxt1 = new Text2('0', {
size: 100,
fill: "#ffffff"
});
scoreTxt1.anchor.set(0.5, 0);
LK.gui.topLeft.addChild(scoreTxt1);
var scoreTxt2 = new Text2('0', {
size: 100,
fill: "#ffffff"
});
scoreTxt2.anchor.set(0.5, 0);
LK.gui.topRight.addChild(scoreTxt2);
game.update = function () {
ball.update();
player1.update();
player2.update();
if (ball.y <= 0) {
score1++;
scoreTxt1.setText(score1);
resetBall();
} else if (ball.y >= 2732) {
score2++;
scoreTxt2.setText(score2);
resetBall();
}
if (ball.intersects(player1) || ball.intersects(player2)) {
ball.speedY *= -1;
}
};
function resetBall() {
ball.x = 1024;
ball.y = 1366;
ball.speedX = 5;
ball.speedY = 5;
}
game.down = function (x, y, obj) {
if (y > 1366) {
player1.x = x;
} else {
player2.x = x;
}
};
game.move = function (x, y, obj) {
if (y > 1366) {
player1.x = x;
} else {
player2.x = x;
}
};
game.up = function (x, y, obj) {
// No action needed on up event
};
white volley ball.
top view of a concave blue (0xADD8E6) plastic button. 4 small black directionnal chevrons engraved : right, left, top , bottom.. Photorealistic
Beach ball. photo
full view of a Beach white towel with colored infinte logo. placed on the sand. photo
Start button in the shape of a white beach volleyball with « START » written on it in black. Photo