/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Define the Missile class var Missile = Container.expand(function () { var self = Container.call(this); var missileGraphics = self.attachAsset('missile', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // Define the Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { self.x = x; self.y = y; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize player var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 200; // Initialize missiles array var missiles = []; // Handle player movement game.down = function (x, y, obj) { player.x = x; player.y = y; }; // Update game state game.update = function () { // Spawn missiles if (LK.ticks % 60 == 0) { var newMissile = new Missile(); newMissile.x = Math.random() * 2048; newMissile.y = -50; missiles.push(newMissile); game.addChild(newMissile); } // Update missiles for (var i = missiles.length - 1; i >= 0; i--) { if (missiles[i].intersects(player)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } if (missiles[i].y > 2732) { missiles[i].destroy(); missiles.splice(i, 1); } } };
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Define the Missile class
var Missile = Container.expand(function () {
var self = Container.call(this);
var missileGraphics = self.attachAsset('missile', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
// Define the Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
self.x = x;
self.y = y;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
// Initialize missiles array
var missiles = [];
// Handle player movement
game.down = function (x, y, obj) {
player.x = x;
player.y = y;
};
// Update game state
game.update = function () {
// Spawn missiles
if (LK.ticks % 60 == 0) {
var newMissile = new Missile();
newMissile.x = Math.random() * 2048;
newMissile.y = -50;
missiles.push(newMissile);
game.addChild(newMissile);
}
// Update missiles
for (var i = missiles.length - 1; i >= 0; i--) {
if (missiles[i].intersects(player)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
if (missiles[i].y > 2732) {
missiles[i].destroy();
missiles.splice(i, 1);
}
}
};
一颗陨石. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
一个宇航员,卡通风格. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
一个太空星空背景,唯美,浪漫. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
一颗陨石,卡通风格. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
一个金币,卡通. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.