/**** * Classes ****/ // Ship class var Ship = Container.expand(function () { var self = Container.call(this); var shipGraphics = self.attachAsset('ship', { anchorX: 0.5, anchorY: 0.5 }); self.orbitIndex = 0; // Start at the outermost orbit self.angle = 0; // Start angle self.jumpToNextOrbit = function () { self.orbitIndex++; if (self.orbitIndex >= orbits.length) { self.orbitIndex = 0; // Reset to the first orbit } }; self.updatePosition = function () { var orbit = orbits[self.orbitIndex]; self.x = orbit.x + orbit.radius * Math.cos(self.angle); self.y = orbit.y + orbit.radius * Math.sin(self.angle); self.angle += 0.05; // Rotate the ship around the orbit }; }); // Orbit class var Orbit = Container.expand(function (radius) { var self = Container.call(this); var orbitGraphics = self.attachAsset('orbit', { anchorX: 0.5, anchorY: 0.5, scaleX: radius, scaleY: radius }); self.radius = radius; self.x = game.width / 2; self.y = game.height / 2; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize orbits // Initialize assets used in this game. var orbits = []; var numOrbits = 5; var orbitSpacing = Math.min(game.width, game.height) / 2 / numOrbits; for (var i = 0; i < numOrbits; i++) { var orbitRadius = orbitSpacing * (i + 1); var orbit = new Orbit(orbitRadius); orbits.push(orbit); game.addChild(orbit); } // Initialize the ship var ship = new Ship(); game.addChild(ship); // Event listener for jumping to the next orbit game.on('down', function (obj) { ship.jumpToNextOrbit(); }); // Game tick event LK.on('tick', function () { ship.updatePosition(); }); // Center the ship on the first orbit ship.x = game.width / 2; ship.y = game.height / 2 + orbits[0].radius;
/****
* Classes
****/
// Ship class
var Ship = Container.expand(function () {
var self = Container.call(this);
var shipGraphics = self.attachAsset('ship', {
anchorX: 0.5,
anchorY: 0.5
});
self.orbitIndex = 0; // Start at the outermost orbit
self.angle = 0; // Start angle
self.jumpToNextOrbit = function () {
self.orbitIndex++;
if (self.orbitIndex >= orbits.length) {
self.orbitIndex = 0; // Reset to the first orbit
}
};
self.updatePosition = function () {
var orbit = orbits[self.orbitIndex];
self.x = orbit.x + orbit.radius * Math.cos(self.angle);
self.y = orbit.y + orbit.radius * Math.sin(self.angle);
self.angle += 0.05; // Rotate the ship around the orbit
};
});
// Orbit class
var Orbit = Container.expand(function (radius) {
var self = Container.call(this);
var orbitGraphics = self.attachAsset('orbit', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: radius,
scaleY: radius
});
self.radius = radius;
self.x = game.width / 2;
self.y = game.height / 2;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize orbits
// Initialize assets used in this game.
var orbits = [];
var numOrbits = 5;
var orbitSpacing = Math.min(game.width, game.height) / 2 / numOrbits;
for (var i = 0; i < numOrbits; i++) {
var orbitRadius = orbitSpacing * (i + 1);
var orbit = new Orbit(orbitRadius);
orbits.push(orbit);
game.addChild(orbit);
}
// Initialize the ship
var ship = new Ship();
game.addChild(ship);
// Event listener for jumping to the next orbit
game.on('down', function (obj) {
ship.jumpToNextOrbit();
});
// Game tick event
LK.on('tick', function () {
ship.updatePosition();
});
// Center the ship on the first orbit
ship.x = game.width / 2;
ship.y = game.height / 2 + orbits[0].radius;
астероид. 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.