/****
* Classes
****/
//<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
****/
//<Write game logic code here, including initializing arrays and variables>
//<Assets used in the game will automatically appear here>
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150;
var rockets = [];
var score = 0;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var livesTxt = new Text2('Lives: 3', {
size: 100,
fill: 0xFFFFFF
});
livesTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(livesTxt);
game.down = function (x, y, obj) {
hero.x = x;
};
game.update = function () {
if (LK.ticks % 60 == 0) {
var newRocket = new Rocket();
newRocket.x = Math.random() * 2048;
newRocket.y = -50;
rockets.push(newRocket);
game.addChild(newRocket);
}
for (var i = rockets.length - 1; i >= 0; i--) {
if (rockets[i].intersects(hero)) {
hero.lives -= 1;
livesTxt.setText('Lives: ' + hero.lives);
rockets[i].destroy();
rockets.splice(i, 1);
if (hero.lives <= 0) {
LK.showGameOver();
}
}
}
score += 1;
scoreTxt.setText('Score: ' + score);
}; /****
* Classes
****/
//<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
****/
//<Write game logic code here, including initializing arrays and variables>
//<Assets used in the game will automatically appear here>
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150;
var rockets = [];
var score = 0;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var livesTxt = new Text2('Lives: 3', {
size: 100,
fill: 0xFFFFFF
});
livesTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(livesTxt);
game.down = function (x, y, obj) {
hero.x = x;
};
game.update = function () {
if (LK.ticks % 60 == 0) {
var newRocket = new Rocket();
newRocket.x = Math.random() * 2048;
newRocket.y = -50;
rockets.push(newRocket);
game.addChild(newRocket);
}
for (var i = rockets.length - 1; i >= 0; i--) {
if (rockets[i].intersects(hero)) {
hero.lives -= 1;
livesTxt.setText('Lives: ' + hero.lives);
rockets[i].destroy();
rockets.splice(i, 1);
if (hero.lives <= 0) {
LK.showGameOver();
}
}
}
score += 1;
scoreTxt.setText('Score: ' + score);
};
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.