Code edit (1 edits merged)
Please save this source code
User prompt
create a class Ball which have a rotating status. And use this class for the player balls.
User prompt
when the user click, the rotating ball stop to rotate, and the other one start rotating around the first one.
Code edit (2 edits merged)
Please save this source code
User prompt
increase the gap between the balls
User prompt
the first ball should rotate around the second one
User prompt
there is a little gap between the 2 balls. twice the with of the balls
User prompt
player is composed by the 2 balls
User prompt
create two ball assets
Code edit (1 edits merged)
Please save this source code
Initial prompt
adofai
/**** * Classes ****/ var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.move = function () { self.y += self.speed; }; }); var Player = Container.expand(function () { var self = Container.call(this); var ship = self.attachAsset('playerShip', { anchorX: 0.5, anchorY: 0.5 }); self.move = function (x, y) { self.x = x; self.y = y; }; }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.move = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize player ship asset // Initialize obstacle asset // Initialize background stars var player = game.addChild(new Player()); player.x = 1024; // Center horizontally player.y = 2400; // Position towards the bottom var obstacles = []; var stars = []; // Generate initial stars for the background for (var i = 0; i < 100; i++) { var star = new Star(); star.x = Math.random() * 2048; star.y = Math.random() * 2732; stars.push(star); game.addChild(star); } // Handle touch move to control player game.on('move', function (obj) { var pos = obj.event.getLocalPosition(game); player.move(pos.x, pos.y); }); LK.on('tick', function () { // Move obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].move(); // Remove off-screen obstacles if (obstacles[i].y > 2732 + 25) { obstacles[i].destroy(); obstacles.splice(i, 1); } // Check collision with player if (player.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Move stars for (var j = stars.length - 1; j >= 0; j--) { stars[j].move(); // Reset star position if it moves off-screen if (stars[j].y > 2732) { stars[j].y = 0; stars[j].x = Math.random() * 2048; } } // Add new obstacle every 60 frames (1 second) if (LK.ticks % 60 == 0) { var newObstacle = new Obstacle(); newObstacle.x = Math.random() * 2048; newObstacle.y = -50; // Start just above the screen obstacles.push(newObstacle); game.addChild(newObstacle); } });
/****
* Classes
****/
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
var ship = self.attachAsset('playerShip', {
anchorX: 0.5,
anchorY: 0.5
});
self.move = function (x, y) {
self.x = x;
self.y = y;
};
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.move = function () {
self.y += self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize player ship asset
// Initialize obstacle asset
// Initialize background stars
var player = game.addChild(new Player());
player.x = 1024; // Center horizontally
player.y = 2400; // Position towards the bottom
var obstacles = [];
var stars = [];
// Generate initial stars for the background
for (var i = 0; i < 100; i++) {
var star = new Star();
star.x = Math.random() * 2048;
star.y = Math.random() * 2732;
stars.push(star);
game.addChild(star);
}
// Handle touch move to control player
game.on('move', function (obj) {
var pos = obj.event.getLocalPosition(game);
player.move(pos.x, pos.y);
});
LK.on('tick', function () {
// Move obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].move();
// Remove off-screen obstacles
if (obstacles[i].y > 2732 + 25) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
// Check collision with player
if (player.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Move stars
for (var j = stars.length - 1; j >= 0; j--) {
stars[j].move();
// Reset star position if it moves off-screen
if (stars[j].y > 2732) {
stars[j].y = 0;
stars[j].x = Math.random() * 2048;
}
}
// Add new obstacle every 60 frames (1 second)
if (LK.ticks % 60 == 0) {
var newObstacle = new Obstacle();
newObstacle.x = Math.random() * 2048;
newObstacle.y = -50; // Start just above the screen
obstacles.push(newObstacle);
game.addChild(newObstacle);
}
});
tête de mort rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tête de mort coter droit en bleu coter gauche en rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tourbillon bleu et rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bone. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tourbillon rouge et bleu. 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.