/**** * Classes ****/ var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.attachAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); }); //<Write imports for supported plugins here> //<Write entity 'classes' with empty functions for important behavior here> var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.lives = 3; self.update = function () { // Hero update logic if needed }; }); var Rocket = Container.expand(function () { var self = Container.call(this); var rocketGraphics = self.attachAsset('rocket', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ //<Assets used in the game will automatically appear here> //<Write game logic code here, including initializing arrays and variables> var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 150; var rockets = []; var score = 0; var scoreTxt = new Text2('Score: ' + score, { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(scoreTxt); var livesTxt = new Text2('Lives: 3', { size: 100, fill: 0xFFFFFF }); livesTxt.anchor.set(0.5, 0); LK.gui.top.addChild(livesTxt); var heart1 = LK.gui.topRight.addChild(new Heart()); heart1.x = -150; heart1.y = 50; var heart2 = LK.gui.topRight.addChild(new Heart()); heart2.x = -250; heart2.y = 50; var heart3 = LK.gui.topRight.addChild(new Heart()); heart3.x = -350; heart3.y = 50; var dragNode = null; game.down = function (x, y, obj) { hero.x = x; dragNode = hero; }; game.update = function () { if (LK.ticks % (60 - Math.floor(score / 100)) == 0) { // Decrease the interval between rocket spawns as the score increases var newRocket = new Rocket(); newRocket.x = Math.random() * 2048; newRocket.y = -50; newRocket.speed += Math.floor(score / 100); // Increase the speed of rockets as the score increases rockets.push(newRocket); game.addChild(newRocket); } for (var i = rockets.length - 1; i >= 0; i--) { if (rockets[i].intersects(hero) && rockets[i].y < hero.y) { hero.lives -= 1; livesTxt.setText('Lives: ' + hero.lives); rockets[i].destroy(); rockets.splice(i, 1); if (hero.lives == 2) { heart3.destroy(); } if (hero.lives == 1) { heart2.destroy(); } if (hero.lives <= 0) { heart1.destroy(); LK.showGameOver(); scoreTxt.setText('Score: ' + score, { fill: 0xFFFFFF }); scoreTxt.visible = true; } } } if (rockets.length > 0) { score += Math.floor(rockets[0].speed / 5); } scoreTxt.setText('Score: ' + score, { fill: 0xFFFFFF }); };
/****
* Classes
****/
var Heart = Container.expand(function () {
var self = Container.call(this);
var heartGraphics = self.attachAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
});
//<Write imports for supported plugins here>
//<Write entity 'classes' with empty functions for important behavior here>
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.lives = 3;
self.update = function () {
// Hero update logic if needed
};
});
var Rocket = Container.expand(function () {
var self = Container.call(this);
var rocketGraphics = self.attachAsset('rocket', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
//<Assets used in the game will automatically appear here>
//<Write game logic code here, including initializing arrays and variables>
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150;
var rockets = [];
var score = 0;
var scoreTxt = new Text2('Score: ' + score, {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(scoreTxt);
var livesTxt = new Text2('Lives: 3', {
size: 100,
fill: 0xFFFFFF
});
livesTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(livesTxt);
var heart1 = LK.gui.topRight.addChild(new Heart());
heart1.x = -150;
heart1.y = 50;
var heart2 = LK.gui.topRight.addChild(new Heart());
heart2.x = -250;
heart2.y = 50;
var heart3 = LK.gui.topRight.addChild(new Heart());
heart3.x = -350;
heart3.y = 50;
var dragNode = null;
game.down = function (x, y, obj) {
hero.x = x;
dragNode = hero;
};
game.update = function () {
if (LK.ticks % (60 - Math.floor(score / 100)) == 0) {
// Decrease the interval between rocket spawns as the score increases
var newRocket = new Rocket();
newRocket.x = Math.random() * 2048;
newRocket.y = -50;
newRocket.speed += Math.floor(score / 100); // Increase the speed of rockets as the score increases
rockets.push(newRocket);
game.addChild(newRocket);
}
for (var i = rockets.length - 1; i >= 0; i--) {
if (rockets[i].intersects(hero) && rockets[i].y < hero.y) {
hero.lives -= 1;
livesTxt.setText('Lives: ' + hero.lives);
rockets[i].destroy();
rockets.splice(i, 1);
if (hero.lives == 2) {
heart3.destroy();
}
if (hero.lives == 1) {
heart2.destroy();
}
if (hero.lives <= 0) {
heart1.destroy();
LK.showGameOver();
scoreTxt.setText('Score: ' + score, {
fill: 0xFFFFFF
});
scoreTxt.visible = true;
}
}
}
if (rockets.length > 0) {
score += Math.floor(rockets[0].speed / 5);
}
scoreTxt.setText('Score: ' + score, {
fill: 0xFFFFFF
});
};
Bildiğin roket yap. Bir tane Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Kalp yap. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Arkaplan olarak uzay yap. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
İnsan. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.