User prompt
kontroller bozuldu
User prompt
Kontroller tek tık yukarı sağa veya sola yok sağ sol olabilir mi
User prompt
sana bir arka plan yüklesem onu oyunun arka planı yapar mısın
User prompt
undo
User prompt
Please set the background as a dark starry outer space sky, featuring distant stars, small glowing nebulae, and slow-moving space dust. The background should have a slight parallax effect to give a sense of depth and motion. All visuals must follow a retro pixel art aesthetic. The background should scroll horizontally as the player moves from left to right, creating the feel of moving through deep space. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
I want to create a 2D platformer game similar to Mario, but set in space. The player controls an astronaut. The game should have high jumps and low gravity. Platforms should be made of space rocks, space station parts, and asteroids. Enemies can be alien creatures or robots. The player should be able to defeat enemies by jumping on them. The goal is to reach the rocket ship at the end of the level while avoiding obstacles. The background should show a starry space scene. Use retro pixel art style graphics. Gameplay details: – The astronaut should be able to double jump due to low gravity. – Add subtle jetpack effects (small pixel exhaust) when jumping. – Include moving, crumbling, and rotating platforms for variety. – Levels should get progressively harder with more enemies and traps. – Traps include laser beams, spike pits, and spinning satellite parts. – Enemies include walking aliens, flying creatures, and robots that shoot. – Enemies drop points when defeated. – Collectible items: glowing stars or crystals for bonus points. – Add checkpoints and respawn mechanics. UI & Scoring: – Score should be visible on screen. – Health is shown as 3 pixel hearts. – Extra lives can be earned through points. – Level ends when the astronaut reaches and enters the rocket ship, which launches with animation. Style: – Keep all visuals in retro pixel art style, including UI. – Background music should be chiptune or 8-bit style. – Add sound effects for jumping, defeating enemies, and collecting items.
User prompt
continue
User prompt
Astro Jump: Space Platformer
Initial prompt
I want to create a 2D platformer game similar to Mario, but set in space. The player controls an astronaut. The game should have high jumps and low gravity. Platforms should be made of space rocks, space station parts, and asteroids. Enemies can be alien creatures or robots. The player should be able to defeat enemies by jumping on them. The goal is to reach the rocket ship at the end of the level while avoiding obstacles. The background should show a space scene. Include a simple scoring system and health (lives). Use retro pixel art style graphics.
/****
* Classes
****/
// Collectible (Star)
var Collectible = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 80;
self.height = 80;
return self;
});
// Enemy (Alien or Robot)
var Enemy = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('alien', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = ENEMY_WIDTH;
self.height = ENEMY_HEIGHT;
self.vx = 3 + Math.random() * 2;
self.direction = Math.random() < 0.5 ? -1 : 1;
self.lastX = 0;
self.update = function () {
self.x += self.vx * self.direction;
// Turn at platform edges
for (var i = 0; i < platforms.length; ++i) {
var p = platforms[i];
if (Math.abs(self.y - p.y) < 10) {
if (self.x - self.width / 2 < p.x - p.width / 2 || self.x + self.width / 2 > p.x + p.width / 2) {
self.direction *= -1;
}
}
}
// Clamp to world
if (self.x < ENEMY_WIDTH / 2) self.direction = 1;
if (self.x > 2048 - ENEMY_WIDTH / 2) self.direction = -1;
self.lastX = self.x;
};
return self;
});
// Platform
var Platform = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = PLATFORM_WIDTH;
self.height = PLATFORM_HEIGHT;
return self;
});
// --- ASSET CLASSES ---
// Player (Astronaut)
var Player = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('astronaut', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = PLAYER_WIDTH;
self.height = PLAYER_HEIGHT;
self.vx = 0;
self.vy = 0;
self.isOnGround = false;
self.lastY = 0;
self.lastX = 0;
self.lastWasIntersectingEnemy = false;
self.lastWasIntersectingRocket = false;
self.update = function () {
// Gravity
self.vy += GRAVITY;
// Move
self.x += self.vx;
self.y += self.vy;
// Clamp to world bounds
if (self.x < PLAYER_WIDTH / 2) self.x = PLAYER_WIDTH / 2;
if (self.x > 2048 - PLAYER_WIDTH / 2) self.x = 2048 - PLAYER_WIDTH / 2;
if (self.y > 2732 - PLAYER_HEIGHT / 2) self.y = 2732 - PLAYER_HEIGHT / 2;
// Platform collision
self.isOnGround = false;
for (var i = 0; i < platforms.length; ++i) {
var p = platforms[i];
// Only check if falling
if (self.vy >= 0 && self.y + self.height / 2 > p.y - p.height / 2 && self.y + self.height / 2 - self.vy <= p.y - p.height / 2) {
// Check horizontal overlap
if (self.x + self.width / 2 > p.x - p.width / 2 && self.x - self.width / 2 < p.x + p.width / 2) {
// Land on platform
self.y = p.y - p.height / 2 - self.height / 2;
self.vy = 0;
self.isOnGround = true;
isJumping = false;
}
}
}
// Enemy collision
var hitEnemy = null;
for (var i = 0; i < enemies.length; ++i) {
var e = enemies[i];
if (self.intersects(e)) {
// Check if landing on top
if (self.lastY + self.height / 2 <= e.y - e.height / 2 && self.y + self.height / 2 > e.y - e.height / 2 && self.vy > 0) {
// Defeat enemy
hitEnemy = e;
break;
} else {
// Hit from side or below: lose life
if (!self.lastWasIntersectingEnemy) {
loseLife();
self.lastWasIntersectingEnemy = true;
}
}
} else {
self.lastWasIntersectingEnemy = false;
}
}
if (hitEnemy) {
// Remove enemy, bounce up
score += 100;
updateScore();
hitEnemy.destroy();
enemies.splice(enemies.indexOf(hitEnemy), 1);
self.vy = JUMP_VELOCITY / 1.5;
}
// Collectibles
for (var i = collectibles.length - 1; i >= 0; --i) {
var c = collectibles[i];
if (self.intersects(c)) {
score += 50;
updateScore();
c.destroy();
collectibles.splice(i, 1);
}
}
// Rocket (level end)
if (!self.lastWasIntersectingRocket && self.intersects(rocket)) {
// Win!
LK.showYouWin();
lastYouWin = true;
}
self.lastWasIntersectingRocket = self.intersects(rocket);
// Fall off screen
if (self.y > 2732) {
loseLife();
}
// Update last positions
self.lastY = self.y;
self.lastX = self.x;
};
return self;
});
// Rocket (Level End)
var Rocket = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('rocket', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 180;
self.height = 260;
return self;
});
/****
* Initialize Game
****/
// --- UI ---
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// --- Astro Jump: Space Platformer Main Game Logic ---
// --- GLOBALS ---
var GRAVITY = 0.3; // Low gravity for floaty jumps
var JUMP_VELOCITY = -18; // High jump
var PLAYER_MOVE_SPEED = 12;
var PLAYER_START_LIVES = 3;
var PLAYER_WIDTH = 120;
var PLAYER_HEIGHT = 140;
var ENEMY_WIDTH = 110;
var ENEMY_HEIGHT = 110;
var PLATFORM_WIDTH = 320;
var PLATFORM_HEIGHT = 60;
var LEVEL_END_X = 1800;
var LEVEL_END_Y = 400;
var platforms = [];
var enemies = [];
var collectibles = [];
var player = null;
var rocket = null;
var score = 0;
var lives = PLAYER_START_LIVES;
var scoreTxt = null;
var livesTxt = null;
var isJumping = false;
var isFalling = false;
var jumpKeyDown = false;
var dragNode = null;
var lastGameOver = false;
var lastYouWin = false;
// --- UI ---
scoreTxt = new Text2('Score: 0', {
size: 90,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
livesTxt = new Text2('Lives: ' + lives, {
size: 90,
fill: "#fff"
});
livesTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(livesTxt);
// --- LEVEL SETUP ---
function setupLevel() {
// Clear previous
for (var i = 0; i < platforms.length; ++i) platforms[i].destroy();
for (var i = 0; i < enemies.length; ++i) enemies[i].destroy();
for (var i = 0; i < collectibles.length; ++i) collectibles[i].destroy();
if (player) player.destroy();
if (rocket) rocket.destroy();
platforms = [];
enemies = [];
collectibles = [];
// Platforms
var platData = [{
x: 400,
y: 2200
}, {
x: 800,
y: 1800
}, {
x: 1200,
y: 1500
}, {
x: 1600,
y: 1200
}, {
x: 1800,
y: 900
}, {
x: 1200,
y: 600
}, {
x: LEVEL_END_X,
y: LEVEL_END_Y
}];
for (var i = 0; i < platData.length; ++i) {
var p = new Platform();
p.x = platData[i].x;
p.y = platData[i].y;
platforms.push(p);
game.addChild(p);
}
// Enemies
var enemyData = [{
x: 800,
y: 1700
}, {
x: 1200,
y: 1400
}, {
x: 1600,
y: 1100
}];
for (var i = 0; i < enemyData.length; ++i) {
var e = new Enemy();
e.x = enemyData[i].x;
e.y = enemyData[i].y;
enemies.push(e);
game.addChild(e);
}
// Collectibles
var starData = [{
x: 400,
y: 2100
}, {
x: 1200,
y: 1400
}, {
x: 1800,
y: 800
}];
for (var i = 0; i < starData.length; ++i) {
var c = new Collectible();
c.x = starData[i].x;
c.y = starData[i].y;
collectibles.push(c);
game.addChild(c);
}
// Rocket
rocket = new Rocket();
rocket.x = LEVEL_END_X;
rocket.y = LEVEL_END_Y - 100;
game.addChild(rocket);
// Player
player = new Player();
player.x = 400;
player.y = 2100;
game.addChild(player);
// Reset UI
updateScore();
updateLives();
lastGameOver = false;
lastYouWin = false;
}
setupLevel();
// --- UI Update ---
function updateScore() {
scoreTxt.setText('Score: ' + score);
}
function updateLives() {
livesTxt.setText('Lives: ' + lives);
}
// --- Lose Life ---
function loseLife() {
if (lastGameOver) return;
lives -= 1;
updateLives();
if (lives <= 0) {
LK.showGameOver();
lastGameOver = true;
} else {
// Respawn player
player.x = 400;
player.y = 2100;
player.vx = 0;
player.vy = 0;
}
}
// --- GAME CONTROLS (Touch/Drag) ---
game.down = function (x, y, obj) {
// Start drag if touch on player
if (player && Math.abs(x - player.x) < player.width / 2 && Math.abs(y - player.y) < player.height / 2) {
dragNode = player;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
game.move = function (x, y, obj) {
if (dragNode === player) {
// Move player horizontally only
player.x = x;
}
};
// --- GAME LOOP ---
game.update = function () {
// Player update
if (player) player.update();
// Enemies update
for (var i = 0; i < enemies.length; ++i) {
enemies[i].update();
}
// Win/Lose handled in player.update
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,362 @@
-/****
+/****
+* Classes
+****/
+// Collectible (Star)
+var Collectible = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = 80;
+ self.height = 80;
+ return self;
+});
+// Enemy (Alien or Robot)
+var Enemy = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('alien', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = ENEMY_WIDTH;
+ self.height = ENEMY_HEIGHT;
+ self.vx = 3 + Math.random() * 2;
+ self.direction = Math.random() < 0.5 ? -1 : 1;
+ self.lastX = 0;
+ self.update = function () {
+ self.x += self.vx * self.direction;
+ // Turn at platform edges
+ for (var i = 0; i < platforms.length; ++i) {
+ var p = platforms[i];
+ if (Math.abs(self.y - p.y) < 10) {
+ if (self.x - self.width / 2 < p.x - p.width / 2 || self.x + self.width / 2 > p.x + p.width / 2) {
+ self.direction *= -1;
+ }
+ }
+ }
+ // Clamp to world
+ if (self.x < ENEMY_WIDTH / 2) self.direction = 1;
+ if (self.x > 2048 - ENEMY_WIDTH / 2) self.direction = -1;
+ self.lastX = self.x;
+ };
+ return self;
+});
+// Platform
+var Platform = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('platform', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = PLATFORM_WIDTH;
+ self.height = PLATFORM_HEIGHT;
+ return self;
+});
+// --- ASSET CLASSES ---
+// Player (Astronaut)
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('astronaut', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = PLAYER_WIDTH;
+ self.height = PLAYER_HEIGHT;
+ self.vx = 0;
+ self.vy = 0;
+ self.isOnGround = false;
+ self.lastY = 0;
+ self.lastX = 0;
+ self.lastWasIntersectingEnemy = false;
+ self.lastWasIntersectingRocket = false;
+ self.update = function () {
+ // Gravity
+ self.vy += GRAVITY;
+ // Move
+ self.x += self.vx;
+ self.y += self.vy;
+ // Clamp to world bounds
+ if (self.x < PLAYER_WIDTH / 2) self.x = PLAYER_WIDTH / 2;
+ if (self.x > 2048 - PLAYER_WIDTH / 2) self.x = 2048 - PLAYER_WIDTH / 2;
+ if (self.y > 2732 - PLAYER_HEIGHT / 2) self.y = 2732 - PLAYER_HEIGHT / 2;
+ // Platform collision
+ self.isOnGround = false;
+ for (var i = 0; i < platforms.length; ++i) {
+ var p = platforms[i];
+ // Only check if falling
+ if (self.vy >= 0 && self.y + self.height / 2 > p.y - p.height / 2 && self.y + self.height / 2 - self.vy <= p.y - p.height / 2) {
+ // Check horizontal overlap
+ if (self.x + self.width / 2 > p.x - p.width / 2 && self.x - self.width / 2 < p.x + p.width / 2) {
+ // Land on platform
+ self.y = p.y - p.height / 2 - self.height / 2;
+ self.vy = 0;
+ self.isOnGround = true;
+ isJumping = false;
+ }
+ }
+ }
+ // Enemy collision
+ var hitEnemy = null;
+ for (var i = 0; i < enemies.length; ++i) {
+ var e = enemies[i];
+ if (self.intersects(e)) {
+ // Check if landing on top
+ if (self.lastY + self.height / 2 <= e.y - e.height / 2 && self.y + self.height / 2 > e.y - e.height / 2 && self.vy > 0) {
+ // Defeat enemy
+ hitEnemy = e;
+ break;
+ } else {
+ // Hit from side or below: lose life
+ if (!self.lastWasIntersectingEnemy) {
+ loseLife();
+ self.lastWasIntersectingEnemy = true;
+ }
+ }
+ } else {
+ self.lastWasIntersectingEnemy = false;
+ }
+ }
+ if (hitEnemy) {
+ // Remove enemy, bounce up
+ score += 100;
+ updateScore();
+ hitEnemy.destroy();
+ enemies.splice(enemies.indexOf(hitEnemy), 1);
+ self.vy = JUMP_VELOCITY / 1.5;
+ }
+ // Collectibles
+ for (var i = collectibles.length - 1; i >= 0; --i) {
+ var c = collectibles[i];
+ if (self.intersects(c)) {
+ score += 50;
+ updateScore();
+ c.destroy();
+ collectibles.splice(i, 1);
+ }
+ }
+ // Rocket (level end)
+ if (!self.lastWasIntersectingRocket && self.intersects(rocket)) {
+ // Win!
+ LK.showYouWin();
+ lastYouWin = true;
+ }
+ self.lastWasIntersectingRocket = self.intersects(rocket);
+ // Fall off screen
+ if (self.y > 2732) {
+ loseLife();
+ }
+ // Update last positions
+ self.lastY = self.y;
+ self.lastX = self.x;
+ };
+ return self;
+});
+// Rocket (Level End)
+var Rocket = Container.expand(function () {
+ var self = Container.call(this);
+ var sprite = self.attachAsset('rocket', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = 180;
+ self.height = 260;
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
+// --- UI ---
var game = new LK.Game({
backgroundColor: 0x000000
-});
\ No newline at end of file
+});
+
+/****
+* Game Code
+****/
+// --- Astro Jump: Space Platformer Main Game Logic ---
+// --- GLOBALS ---
+var GRAVITY = 0.3; // Low gravity for floaty jumps
+var JUMP_VELOCITY = -18; // High jump
+var PLAYER_MOVE_SPEED = 12;
+var PLAYER_START_LIVES = 3;
+var PLAYER_WIDTH = 120;
+var PLAYER_HEIGHT = 140;
+var ENEMY_WIDTH = 110;
+var ENEMY_HEIGHT = 110;
+var PLATFORM_WIDTH = 320;
+var PLATFORM_HEIGHT = 60;
+var LEVEL_END_X = 1800;
+var LEVEL_END_Y = 400;
+var platforms = [];
+var enemies = [];
+var collectibles = [];
+var player = null;
+var rocket = null;
+var score = 0;
+var lives = PLAYER_START_LIVES;
+var scoreTxt = null;
+var livesTxt = null;
+var isJumping = false;
+var isFalling = false;
+var jumpKeyDown = false;
+var dragNode = null;
+var lastGameOver = false;
+var lastYouWin = false;
+// --- UI ---
+scoreTxt = new Text2('Score: 0', {
+ size: 90,
+ fill: "#fff"
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+livesTxt = new Text2('Lives: ' + lives, {
+ size: 90,
+ fill: "#fff"
+});
+livesTxt.anchor.set(0.5, 0);
+LK.gui.topRight.addChild(livesTxt);
+// --- LEVEL SETUP ---
+function setupLevel() {
+ // Clear previous
+ for (var i = 0; i < platforms.length; ++i) platforms[i].destroy();
+ for (var i = 0; i < enemies.length; ++i) enemies[i].destroy();
+ for (var i = 0; i < collectibles.length; ++i) collectibles[i].destroy();
+ if (player) player.destroy();
+ if (rocket) rocket.destroy();
+ platforms = [];
+ enemies = [];
+ collectibles = [];
+ // Platforms
+ var platData = [{
+ x: 400,
+ y: 2200
+ }, {
+ x: 800,
+ y: 1800
+ }, {
+ x: 1200,
+ y: 1500
+ }, {
+ x: 1600,
+ y: 1200
+ }, {
+ x: 1800,
+ y: 900
+ }, {
+ x: 1200,
+ y: 600
+ }, {
+ x: LEVEL_END_X,
+ y: LEVEL_END_Y
+ }];
+ for (var i = 0; i < platData.length; ++i) {
+ var p = new Platform();
+ p.x = platData[i].x;
+ p.y = platData[i].y;
+ platforms.push(p);
+ game.addChild(p);
+ }
+ // Enemies
+ var enemyData = [{
+ x: 800,
+ y: 1700
+ }, {
+ x: 1200,
+ y: 1400
+ }, {
+ x: 1600,
+ y: 1100
+ }];
+ for (var i = 0; i < enemyData.length; ++i) {
+ var e = new Enemy();
+ e.x = enemyData[i].x;
+ e.y = enemyData[i].y;
+ enemies.push(e);
+ game.addChild(e);
+ }
+ // Collectibles
+ var starData = [{
+ x: 400,
+ y: 2100
+ }, {
+ x: 1200,
+ y: 1400
+ }, {
+ x: 1800,
+ y: 800
+ }];
+ for (var i = 0; i < starData.length; ++i) {
+ var c = new Collectible();
+ c.x = starData[i].x;
+ c.y = starData[i].y;
+ collectibles.push(c);
+ game.addChild(c);
+ }
+ // Rocket
+ rocket = new Rocket();
+ rocket.x = LEVEL_END_X;
+ rocket.y = LEVEL_END_Y - 100;
+ game.addChild(rocket);
+ // Player
+ player = new Player();
+ player.x = 400;
+ player.y = 2100;
+ game.addChild(player);
+ // Reset UI
+ updateScore();
+ updateLives();
+ lastGameOver = false;
+ lastYouWin = false;
+}
+setupLevel();
+// --- UI Update ---
+function updateScore() {
+ scoreTxt.setText('Score: ' + score);
+}
+function updateLives() {
+ livesTxt.setText('Lives: ' + lives);
+}
+// --- Lose Life ---
+function loseLife() {
+ if (lastGameOver) return;
+ lives -= 1;
+ updateLives();
+ if (lives <= 0) {
+ LK.showGameOver();
+ lastGameOver = true;
+ } else {
+ // Respawn player
+ player.x = 400;
+ player.y = 2100;
+ player.vx = 0;
+ player.vy = 0;
+ }
+}
+// --- GAME CONTROLS (Touch/Drag) ---
+game.down = function (x, y, obj) {
+ // Start drag if touch on player
+ if (player && Math.abs(x - player.x) < player.width / 2 && Math.abs(y - player.y) < player.height / 2) {
+ dragNode = player;
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+game.move = function (x, y, obj) {
+ if (dragNode === player) {
+ // Move player horizontally only
+ player.x = x;
+ }
+};
+// --- GAME LOOP ---
+game.update = function () {
+ // Player update
+ if (player) player.update();
+ // Enemies update
+ for (var i = 0; i < enemies.length; ++i) {
+ enemies[i].update();
+ }
+ // Win/Lose handled in player.update
+};
\ No newline at end of file