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.canDoubleJump = true; self.lastY = 0; self.lastX = 0; self.lastWasIntersectingEnemy = false; self.lastWasIntersectingRocket = false; self.jetpackExhaust = null; self.update = function () { // Gravity self.vy += GRAVITY; // Jetpack exhaust effect (show when jumping or double jumping) if (self.vy < -2) { if (!self.jetpackExhaust) { self.jetpackExhaust = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.0, scaleX: 0.3, scaleY: 0.3, y: self.height / 2 + 10 }); self.jetpackExhaust.alpha = 0.7; } self.jetpackExhaust.x = 0; self.jetpackExhaust.y = self.height / 2 + 10; self.jetpackExhaust.visible = true; } else if (self.jetpackExhaust) { self.jetpackExhaust.visible = false; } // 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; self.canDoubleJump = 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(); if (LK.getSound && LK.getSound('enemyDefeat')) LK.getSound('enemyDefeat').play(); 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(); if (LK.getSound && LK.getSound('collect')) LK.getSound('collect').play(); 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 ****/ // --- GLOBALS --- // --- Astro Jump: Space Platformer Main Game Logic --- 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; // --- STATIC STARFIELD BACKGROUND --- // Create a simple static starfield background (retro pixel art style) var staticStarBg = new Container(); for (var i = 0; i < 80; ++i) { var star = LK.getAsset('star', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.15 + Math.random() * 0.2, scaleY: 0.15 + Math.random() * 0.2 }); star.x = Math.random() * 2048; star.y = Math.random() * 2732; star.alpha = 0.5 + Math.random() * 0.5; staticStarBg.addChild(star); } game.addChildAt(staticStarBg, 0); // Always behind everything // --- UI --- scoreTxt = new Text2('Score: 0', { size: 90, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Pixel heart asset livesTxt = new Container(); livesTxt.hearts = []; for (var i = 0; i < PLAYER_START_LIVES; ++i) { var heart = LK.getAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); heart.x = i * 70; heart.y = 0; livesTxt.addChild(heart); livesTxt.hearts.push(heart); } livesTxt.x = 0; livesTxt.y = 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(); LK.playMusic('chiptune'); // --- UI Update --- function updateScore() { scoreTxt.setText('Score: ' + score); } function updateLives() { for (var i = 0; i < livesTxt.hearts.length; ++i) { livesTxt.hearts[i].visible = i < 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; } else if (player) { // Jump or double jump if tap anywhere else if (player.isOnGround) { player.vy = JUMP_VELOCITY; player.isOnGround = false; player.canDoubleJump = true; // Play jump sound if available if (LK.getSound && LK.getSound('jump')) LK.getSound('jump').play(); } else if (player.canDoubleJump) { player.vy = JUMP_VELOCITY; player.canDoubleJump = false; // Play jump sound if available if (LK.getSound && LK.getSound('jump')) LK.getSound('jump').play(); } } }; 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 () { // --- Static background: no parallax update needed --- // 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
@@ -226,101 +226,24 @@
var jumpKeyDown = false;
var dragNode = null;
var lastGameOver = false;
var lastYouWin = false;
-// --- PARALLAX STARFIELD BACKGROUND ---
-// Each layer is a container of "stars" or "dust" or "nebulae" (pixel art style)
-var starBgLayers = [];
-var STARFIELD_LAYERS = [{
- count: 40,
- color: 0xffffff,
- size: 3,
- speed: 0.15,
- alpha: 0.7
-},
-// far stars
-{
- count: 25,
- color: 0x99ccff,
- size: 5,
- speed: 0.25,
- alpha: 0.5
-},
-// blue stars
-{
- count: 10,
- color: 0xffeedd,
- size: 8,
- speed: 0.35,
- alpha: 0.4
-},
-// warm stars
-{
- count: 6,
- color: 0x7f3fff,
- size: 32,
- speed: 0.10,
- alpha: 0.18,
- nebula: true
-},
-// nebulae
-{
- count: 12,
- color: 0xcccccc,
- size: 12,
- speed: 0.5,
- alpha: 0.12,
- dust: true
-} // space dust
-];
-var starBgContainer = new Container();
-game.addChildAt(starBgContainer, 0); // Always behind everything
-function createStarPixelArt(color, size, alpha, isNebula, isDust) {
- // Use a star or nebula or dust "pixel art" using the built-in shape asset
- var assetId = 'star_pixel_' + color + '_' + size + '_' + (isNebula ? 'neb' : isDust ? 'dust' : 'star');
- if (!LK._assets || !LK._assets[assetId]) {
- if (isNebula) {} else if (isDust) {} else {}
- }
- var s = LK.getAsset(assetId, {
+// --- STATIC STARFIELD BACKGROUND ---
+// Create a simple static starfield background (retro pixel art style)
+var staticStarBg = new Container();
+for (var i = 0; i < 80; ++i) {
+ var star = LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: 1,
- scaleY: 1
+ scaleX: 0.15 + Math.random() * 0.2,
+ scaleY: 0.15 + Math.random() * 0.2
});
- s.alpha = alpha;
- return s;
+ star.x = Math.random() * 2048;
+ star.y = Math.random() * 2732;
+ star.alpha = 0.5 + Math.random() * 0.5;
+ staticStarBg.addChild(star);
}
-// Create parallax starfield layers
-for (var l = 0; l < STARFIELD_LAYERS.length; ++l) {
- var layer = new Container();
- var layerConf = STARFIELD_LAYERS[l];
- layer._parallaxSpeed = layerConf.speed;
- layer._stars = [];
- for (var i = 0; i < layerConf.count; ++i) {
- var s = createStarPixelArt(layerConf.color, layerConf.size, layerConf.alpha, !!layerConf.nebula, !!layerConf.dust);
- // Randomize position
- s.x = Math.random() * 2048;
- s.y = Math.random() * 2732;
- // For nebulae, randomize scale and rotation for variety
- if (layerConf.nebula) {
- s.scaleX = 0.8 + Math.random() * 1.2;
- s.scaleY = 0.8 + Math.random() * 1.2;
- s.rotation = Math.random() * Math.PI * 2;
- }
- // For dust, randomize scale and alpha
- if (layerConf.dust) {
- s.scaleX = 0.5 + Math.random();
- s.scaleY = 0.5 + Math.random();
- s.alpha = layerConf.alpha * (0.5 + Math.random());
- }
- layer.addChild(s);
- layer._stars.push(s);
- }
- starBgContainer.addChild(layer);
- starBgLayers.push(layer);
-}
-// Used to track last player X for parallax
-var lastPlayerX = 0;
+game.addChildAt(staticStarBg, 0); // Always behind everything
// --- UI ---
scoreTxt = new Text2('Score: 0', {
size: 90,
fill: "#fff"
@@ -494,36 +417,9 @@
}
};
// --- GAME LOOP ---
game.update = function () {
- // --- Parallax background update ---
- // Only scroll if player exists
- if (player) {
- // Calculate horizontal movement since last frame
- var dx = player.x - lastPlayerX;
- for (var l = 0; l < starBgLayers.length; ++l) {
- var layer = starBgLayers[l];
- // Parallax: move layer in opposite direction to player movement, at layer speed
- layer.x -= dx * layer._parallaxSpeed;
- // Wrap stars horizontally for infinite effect
- for (var s = 0; s < layer._stars.length; ++s) {
- var star = layer._stars[s];
- var globalX = layer.x + star.x;
- if (globalX < -100) {
- star.x += 2048 + 200;
- } else if (globalX > 2048 + 100) {
- star.x -= 2048 + 200;
- }
- // For nebula/dust, add slow vertical drift for depth
- if (star.scaleY && (l === 3 || l === 4)) {
- star.y += Math.sin(Date.now() / 4000 + s) * 0.08 + 0.04 * (l - 2);
- if (star.y > 2732) star.y -= 2732;
- if (star.y < 0) star.y += 2732;
- }
- }
- }
- lastPlayerX = player.x;
- }
+ // --- Static background: no parallax update needed ---
// Player update
if (player) player.update();
// Enemies update
for (var i = 0; i < enemies.length; ++i) {