User prompt
Do that also in the top right corner of the game
User prompt
After you beat a level show back to main menu and you go to the main menu
User prompt
It’s not there just add it
User prompt
Add the back to main menu in the top right corner
User prompt
After you go in a level add back to main menu in the top right corner
User prompt
Put the option to go back to main menu on the top right corner
User prompt
Remove the button after you win back to main menu
User prompt
U didn’t mean the top right corner one put it back
User prompt
Remove back to main menu in the middle of the screen show that when the level is finished
User prompt
After I goin in a level show go back to menu in the top right corner
User prompt
After you win a level and you press back to main menu it will show the game and the text please fix this
User prompt
After you beat a level show an option of to go back to main menu
User prompt
So when you get 30 points add +150 coins to the player
User prompt
Make Erin’s atventure only 30 points
User prompt
Make 2 new levels and the first one will be called Erin’s atventure continuation and the second Dash and in the first one make the spikes closer and in the second just use more spikes and keep the close
User prompt
Just make them like the last 3 levels
User prompt
Try again
User prompt
The game is looking great but make the text more thicker
User prompt
Make the character visible again after it explodes
User prompt
After the character turns into small peices reastart from the start
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: playerSprite' in or related to this line: 'if (playerSprite && playerSprite.color) {' Line Number: 585
User prompt
Remove the red effect when you die just make the character explode into small peices
User prompt
Make the start of every level a little bit longer
User prompt
When I die reset to the start
User prompt
When I die don’t show play again just reset
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
coins: 0,
claimed: {}
});
/****
* Classes
****/
// Obstacle class (tall block)
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obsSprite = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1
});
self.speed = 22;
self.update = function () {
self.x -= self.speed;
};
return self;
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerSprite = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1
});
// Apply skin color if selected
var skinColors = {
"skin_red": 0xe74c3c,
"skin_green": 0x2ecc71,
"skin_gold": 0xf1c40f
};
if (storage.selectedSkin && skinColors[storage.selectedSkin]) {
playerSprite.color = skinColors[storage.selectedSkin];
// LK shape assets support .color property for tinting
}
// Physics
self.vy = 0;
self.isJumping = false;
self.gravity = 2.2;
self.jumpStrength = -48;
self.groundY = 0; // Set after ground is created
// Update method
self.update = function () {
// Apply gravity
self.vy += self.gravity;
self.y += self.vy;
// Ground collision
if (self.y > self.groundY) {
self.y = self.groundY;
self.vy = 0;
self.isJumping = false;
}
};
// Jump method
self.jump = function () {
if (!self.isJumping && self.y >= self.groundY) {
self.vy = self.jumpStrength;
self.isJumping = true;
// Start 360-degree rotation tween on playerSprite
tween(playerSprite, {
rotation: playerSprite.rotation + Math.PI * 2
}, {
duration: 400,
easing: tween.linear
});
}
};
return self;
});
// Spike class (obstacle)
var Spike = Container.expand(function () {
var self = Container.call(this);
var spikeSprite = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1
});
self.speed = 22; // Moves left
self.update = function () {
self.x -= self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222831
});
/****
* Game Code
****/
// --- LEVEL DATA ---
// Player: blue square
// Ground: gray rectangle
// Spike: red triangle (approximate with a tall, thin box for MVP)
// Obstacle: purple rectangle
var LEVELS = [{
name: "First Steps",
difficulty: "Easy",
color: 0x2ecc71,
minGap: 500,
maxGap: 900,
types: ['spike', 'obstacle', 'spike'],
intro: "Welcome to your first steps!"
}, {
name: "Erin's Adventure",
difficulty: "Medium",
color: 0xf1c40f,
minGap: 500,
maxGap: 900,
types: ['spike', 'obstacle', 'spike'],
intro: "A trickier journey awaits."
}, {
name: "Final Steps",
difficulty: "Hard",
color: 0xe74c3c,
minGap: 500,
maxGap: 900,
types: ['spike', 'obstacle', 'spike'],
intro: "Only the brave survive!"
}, {
name: "Erin’s atventure continuation",
difficulty: "Hard",
color: 0x8e44ad,
minGap: 320,
maxGap: 480,
types: ['spike', 'spike', 'obstacle', 'spike', 'spike'],
intro: "The spikes are closer than ever. Time your jumps perfectly!"
}, {
name: "Dash",
difficulty: "Extreme",
color: 0x16a085,
minGap: 220,
maxGap: 350,
types: ['spike', 'spike', 'spike', 'obstacle', 'spike', 'spike', 'spike'],
intro: "Dash through a gauntlet of spikes! Can you survive?"
}];
// --- MENU STATE ---
var MENU_STATE = {
MAIN: 0,
LEVEL_SELECT: 1,
PLAYING: 2
};
var menuState = MENU_STATE.MAIN;
var selectedLevel = 0;
// --- UI ELEMENTS ---
var menuContainer = new Container();
var levelSelectContainer = new Container();
var introText = null;
// --- GAME CONSTANTS ---
var GROUND_HEIGHT = 120;
var PLAYER_SIZE = 120;
var PLAYER_START_X = 400;
var OBSTACLE_MIN_GAP = 600;
var OBSTACLE_MAX_GAP = 1100;
var OBSTACLE_TYPES = ['spike', 'obstacle'];
var OBSTACLE_Y = 2732 - GROUND_HEIGHT;
// --- GAME STATE ---
var player;
var ground;
var obstacles = [];
var score = 0;
var scoreTxt;
var lastObstacleX = 0;
var isGameOver = false;
// --- UI HELPERS ---
function clearMenuUI() {
if (menuContainer.parent) menuContainer.parent.removeChild(menuContainer);
if (levelSelectContainer.parent) levelSelectContainer.parent.removeChild(levelSelectContainer);
if (introText && introText.parent) introText.parent.removeChild(introText);
}
// --- MAIN MENU ---
function showMainMenu() {
clearMenuUI();
menuState = MENU_STATE.MAIN;
menuContainer.removeChildren();
// Title
var title = new Text2("Geometry Dash", {
size: 180,
fill: 0xFFFFFF,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 12
});
title.anchor.set(0.5, 0);
title.x = 2048 / 2;
title.y = 400;
menuContainer.addChild(title);
// Play button
var playBtn = new Text2("Play", {
size: 140,
fill: 0x2ECC71,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 10
});
playBtn.anchor.set(0.5, 0.5);
playBtn.x = 2048 / 2;
playBtn.y = 1000;
playBtn.interactive = true;
playBtn.buttonMode = true;
playBtn.down = function () {
showLevelSelect();
};
menuContainer.addChild(playBtn);
// Shop button
var shopBtn = new Text2("Shop", {
size: 120,
fill: 0xf1c40f,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 8
});
shopBtn.anchor.set(0.5, 0.5);
shopBtn.x = 2048 / 2;
shopBtn.y = 1200;
shopBtn.interactive = true;
shopBtn.buttonMode = true;
shopBtn.down = function () {
showShop();
};
menuContainer.addChild(shopBtn);
// Add to game
game.addChild(menuContainer);
}
// --- SHOP ---
var shopContainer = new Container();
var SHOP_ITEMS = [{
id: "skin_red",
name: "Red Skin",
price: 30,
color: 0xe74c3c
}, {
id: "skin_green",
name: "Green Skin",
price: 30,
color: 0x2ecc71
}, {
id: "skin_gold",
name: "Gold Skin",
price: 100,
color: 0xf1c40f
}];
function showShop() {
clearMenuUI();
menuState = MENU_STATE.MAIN;
shopContainer.removeChildren();
// Title
var shopTitle = new Text2("Shop", {
size: 150,
fill: 0xFFFFFF,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 10
});
shopTitle.anchor.set(0.5, 0);
shopTitle.x = 2048 / 2;
shopTitle.y = 300;
shopContainer.addChild(shopTitle);
// Coin display
var coins = storage.coins || 0;
var coinTxt = new Text2("Coins: " + coins, {
size: 100,
fill: 0xf1c40f,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 7
});
coinTxt.anchor.set(0.5, 0);
coinTxt.x = 2048 / 2;
coinTxt.y = 500;
shopContainer.addChild(coinTxt);
// List items
for (var i = 0; i < SHOP_ITEMS.length; i++) {
(function (idx) {
var item = SHOP_ITEMS[idx];
var owned = storage["owned_" + item.id] === true;
var y = 700 + idx * 220;
var itemTxt = new Text2(item.name, {
size: 100,
fill: "#" + item.color.toString(16).padStart(6, "0"),
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 7
});
itemTxt.anchor.set(0, 0.5);
itemTxt.x = 400;
itemTxt.y = y;
shopContainer.addChild(itemTxt);
var priceTxt = new Text2(owned ? "Owned" : item.price + " coins", {
size: 90,
fill: owned ? 0x2ecc71 : 0xffffff,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 6
});
priceTxt.anchor.set(0.5, 0.5);
priceTxt.x = 1200;
priceTxt.y = y;
shopContainer.addChild(priceTxt);
// Buy/select button
var btnTxt = owned ? storage.selectedSkin === item.id ? "Selected" : "Select" : "Buy";
var btn = new Text2(btnTxt, {
size: 90,
fill: owned ? storage.selectedSkin === item.id ? 0x2ecc71 : 0x3498db : 0xf1c40f,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 6
});
btn.anchor.set(0.5, 0.5);
btn.x = 1700;
btn.y = y;
btn.interactive = true;
btn.buttonMode = true;
btn.down = function () {
if (owned) {
// Select skin
storage.selectedSkin = item.id;
showShop();
} else {
// Try to buy
var coins = storage.coins || 0;
if (coins >= item.price) {
storage.coins = coins - item.price;
storage["owned_" + item.id] = true;
storage.selectedSkin = item.id;
showShop();
} else {
priceTxt.setText("Not enough!");
priceTxt.fill = 0xe74c3c;
}
}
};
shopContainer.addChild(btn);
})(i);
}
// Back button
var backBtn = new Text2("Back", {
size: 90,
fill: 0x888888,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 6
});
backBtn.anchor.set(0.5, 0.5);
backBtn.x = 2048 / 2;
backBtn.y = 700 + SHOP_ITEMS.length * 220 + 100;
backBtn.interactive = true;
backBtn.buttonMode = true;
backBtn.down = function () {
// Remove shop UI before showing main menu
if (shopContainer.parent) shopContainer.parent.removeChild(shopContainer);
showMainMenu();
};
shopContainer.addChild(backBtn);
game.addChild(shopContainer);
}
// --- LEVEL SELECT MENU ---
function showLevelSelect() {
clearMenuUI();
menuState = MENU_STATE.LEVEL_SELECT;
levelSelectContainer.removeChildren();
// Title
var selTitle = new Text2("Select Level", {
size: 150,
fill: 0xFFFFFF,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 10
});
selTitle.anchor.set(0.5, 0);
selTitle.x = 2048 / 2;
selTitle.y = 300;
levelSelectContainer.addChild(selTitle);
// Level buttons
for (var i = 0; i < LEVELS.length; i++) {
(function (idx) {
var lvl = LEVELS[idx];
var btn = new Text2(lvl.name + " (" + lvl.difficulty + ")", {
size: 110,
fill: "#" + lvl.color.toString(16).padStart(6, "0"),
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 8
});
btn.anchor.set(0.5, 0.5);
btn.x = 2048 / 2;
btn.y = 600 + idx * 250;
btn.interactive = true;
btn.buttonMode = true;
btn.down = function () {
selectedLevel = idx;
showLevelIntro();
};
levelSelectContainer.addChild(btn);
})(i);
}
// Back button
var backBtn = new Text2("Back", {
size: 90,
fill: 0x888888,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 6
});
backBtn.anchor.set(0.5, 0.5);
backBtn.x = 2048 / 2;
backBtn.y = 600 + LEVELS.length * 250 + 100;
backBtn.interactive = true;
backBtn.buttonMode = true;
backBtn.down = function () {
showMainMenu();
};
levelSelectContainer.addChild(backBtn);
game.addChild(levelSelectContainer);
}
// --- LEVEL INTRO ---
function showLevelIntro() {
clearMenuUI();
menuState = MENU_STATE.LEVEL_SELECT;
var lvl = LEVELS[selectedLevel];
// Coin rewards per level
var COIN_REWARDS = [20, 50, 100];
var rewardText = lvl.name + "\nDifficulty: " + lvl.difficulty + "\n\n" + lvl.intro + "\n\nTap to Start";
var showClaim = false;
var coinsToClaim = 0;
if (storage.claimed && storage.claimed[selectedLevel] === false && storage.lastCompletedLevel !== undefined && storage.lastCompletedLevel == selectedLevel) {
// Player just beat this level and hasn't claimed coins yet
showClaim = true;
coinsToClaim = COIN_REWARDS[selectedLevel];
rewardText += "\n\n🎉 Level Complete! 🎉\nClaim +" + coinsToClaim + " coins!";
}
introText = new Text2(rewardText, {
size: 100,
fill: "#" + lvl.color.toString(16).padStart(6, "0"),
align: "center",
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 7
});
introText.anchor.set(0.5, 0.5);
introText.x = 2048 / 2;
introText.y = 1200;
introText.interactive = true;
introText.buttonMode = true;
introText.down = function () {
if (showClaim) return; // Don't start level if claim is available
startLevel(selectedLevel);
};
game.addChild(introText);
// Show claim button if eligible
if (showClaim) {
var claimBtn = new Text2("Claim +" + coinsToClaim + " coins", {
size: 110,
fill: 0xFFD700,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 8
});
claimBtn.anchor.set(0.5, 0.5);
claimBtn.x = 2048 / 2;
claimBtn.y = introText.y + 350;
claimBtn.interactive = true;
claimBtn.buttonMode = true;
claimBtn.down = function () {
// Add coins and mark as claimed
storage.coins = (storage.coins || 0) + coinsToClaim;
if (!storage.claimed) storage.claimed = {};
storage.claimed[selectedLevel] = true;
// Remove lastCompletedLevel so claim can't be repeated
delete storage.lastCompletedLevel;
// Update UI
claimBtn.setText("Claimed!");
claimBtn.interactive = false;
claimBtn.buttonMode = false;
};
game.addChild(claimBtn);
}
}
// --- START LEVEL ---
function startLevel(levelIdx) {
clearMenuUI();
menuState = MENU_STATE.PLAYING;
// Set level params
var lvl = LEVELS[levelIdx];
OBSTACLE_MIN_GAP = lvl.minGap;
OBSTACLE_MAX_GAP = lvl.maxGap;
OBSTACLE_TYPES = lvl.types;
// Reset game state
resetGame();
// Show score
scoreTxt.setText("0");
scoreTxt.visible = true;
// Show ground and player
if (!ground) {
ground = LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 2732
});
game.addChild(ground);
}
if (!player) {
player = new Player();
player.x = PLAYER_START_X;
player.groundY = 2732 - GROUND_HEIGHT;
player.y = player.groundY;
game.addChild(player);
}
// Initial obstacle
lastObstacleX = 1200 + 700; //{2I} // Add extra distance for a longer start
spawnObstacle();
}
// --- SCORE TEXT ---
scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF,
fontWeight: "bold",
stroke: 0x000000,
strokeThickness: 8
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.visible = false;
// --- INITIALIZE: show main menu ---
showMainMenu();
// Helper: spawn obstacle
function spawnObstacle() {
// Randomly pick type
var type = OBSTACLE_TYPES[Math.floor(Math.random() * OBSTACLE_TYPES.length)];
var obs;
if (type === 'spike') {
obs = new Spike();
obs.x = 2048 + 100;
obs.y = OBSTACLE_Y;
} else {
obs = new Obstacle();
obs.x = 2048 + 100;
obs.y = OBSTACLE_Y;
}
obstacles.push(obs);
game.addChild(obs);
lastObstacleX = obs.x;
}
// Helper: reset game state
function resetGame() {
// Remove obstacles
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].destroy();
}
obstacles = [];
// Reset player
if (player) {
player.x = PLAYER_START_X;
player.y = player.groundY;
player.vy = 0;
player.isJumping = false;
player.visible = true; // Make player visible again after explosion
}
// Reset score
score = 0;
scoreTxt.setText(score);
lastObstacleX = 1200;
isGameOver = false;
}
// Touch/click to jump
game.down = function (x, y, obj) {
if (menuState !== MENU_STATE.PLAYING) return;
if (isGameOver) return;
player.jump();
};
// Main update loop
game.update = function () {
if (menuState !== MENU_STATE.PLAYING) return;
if (isGameOver) return;
// Update player
player.update();
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obs = obstacles[i];
obs.update();
// Remove if off screen
if (obs.x < -200) {
obs.destroy();
obstacles.splice(i, 1);
continue;
}
// Collision detection
if (player.intersects(obs)) {
// Explode player into small pieces
if (player && player.parent) {
var numPieces = 12;
var centerX = player.x;
var centerY = player.y;
var pieceSize = 32;
for (var p = 0; p < numPieces; p++) {
(function (pieceIdx) {
var angle = Math.PI * 2 / numPieces * pieceIdx;
var px = centerX;
var py = centerY - PLAYER_SIZE / 2 + pieceSize / 2;
var piece = new Container();
var pieceSprite = piece.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
width: pieceSize,
height: pieceSize
});
// Use same color as player
var playerSpriteRef = player && player.childAt ? player.childAt(0) : null;
if (playerSpriteRef && playerSpriteRef.color) {
pieceSprite.color = playerSpriteRef.color;
}
piece.x = px;
piece.y = py;
game.addChild(piece);
// Animate outward with random velocity and fade out
var speed = 32 + Math.random() * 32;
var dx = Math.cos(angle) * speed;
var dy = Math.sin(angle) * speed - 10 + Math.random() * 20;
tween(piece, {
x: px + dx * 16,
y: py + dy * 16,
alpha: 0
}, {
duration: 700 + Math.random() * 200,
easing: tween.easeOutCubic,
onComplete: function onComplete() {
piece.destroy();
}
});
})(p);
}
// Hide player sprite immediately
player.visible = false;
}
isGameOver = true;
// Delay restart until after explosion animation
LK.setTimeout(function () {
startLevel(selectedLevel);
}, 800);
return;
}
}
// Score: increase as player passes obstacles
for (var j = 0; j < obstacles.length; j++) {
var o = obstacles[j];
if (!o.passed && o.x + 60 < player.x) {
o.passed = true;
score += 1;
scoreTxt.setText(score);
}
}
// Win condition: pass 10 obstacles (easy), 15 (medium), 20 (hard), 30 (Erin’s atventure continuation), 40 (Dash)
var winScores = [10, 15, 20, 30, 40];
if (score >= winScores[selectedLevel]) {
isGameOver = true;
// Mark level as completed for coin claim
storage.lastCompletedLevel = selectedLevel;
if (!storage.claimed) storage.claimed = {};
storage.claimed[selectedLevel] = storage.claimed[selectedLevel] || false;
// Award +150 coins if Erin’s atventure continuation (index 3)
if (selectedLevel === 3) {
storage.coins = (storage.coins || 0) + 150;
}
LK.setTimeout(function () {
showLevelIntro();
}, 600);
return;
}
// Spawn new obstacles
if (obstacles.length === 0 || 2048 - lastObstacleX > OBSTACLE_MIN_GAP + Math.floor(Math.random() * (OBSTACLE_MAX_GAP - OBSTACLE_MIN_GAP))) {
spawnObstacle();
}
};
// (gameover event handler removed, as game over popup is never shown) ===================================================================
--- original.js
+++ change.js
@@ -667,8 +667,12 @@
// Mark level as completed for coin claim
storage.lastCompletedLevel = selectedLevel;
if (!storage.claimed) storage.claimed = {};
storage.claimed[selectedLevel] = storage.claimed[selectedLevel] || false;
+ // Award +150 coins if Erin’s atventure continuation (index 3)
+ if (selectedLevel === 3) {
+ storage.coins = (storage.coins || 0) + 150;
+ }
LK.setTimeout(function () {
showLevelIntro();
}, 600);
return;