User prompt
Add a next page button for owner commands
User prompt
Add a gem shop ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fix it
User prompt
Add a daily shop ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add 10 more stuff to the shop ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add a shop ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add 13 owner commands
User prompt
Add 13 more owner commands
User prompt
Make owner commands on top
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'for (var x = 0; x <= level.length + 1000; x += 200) {' Line Number: 1501
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'if (levelData[currentLevel].shipMode) {' Line Number: 1482
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'if (levelData[currentLevel].shipMode) {' Line Number: 1484
User prompt
Add daily level ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add 17 more levels in the next page
User prompt
Make level 51 start with a swing ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ad coins for each level ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add a swing ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the video so people know how to beat it
User prompt
Add a video button
User prompt
Make all levels different from each level
User prompt
Add owner commands button
User prompt
Make the speed more faster
User prompt
Make level 1 start with a ship
Code edit (1 edits merged)
Please save this source code
User prompt
Geometry Dash: 50 Level Challenge
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Checkpoint = Container.expand(function (x, y) {
var self = Container.call(this);
var checkpointGraphics = self.attachAsset('checkpoint', {
anchorX: 0.5,
anchorY: 1.0
});
self.x = x;
self.y = y;
self.activated = false;
return self;
});
var Coin = Container.expand(function (x, y) {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.collected = false;
self.rotationSpeed = 0.05;
self.update = function () {
if (!self.collected) {
coinGraphics.rotation += self.rotationSpeed;
}
};
return self;
});
var Ground = Container.expand(function (x, y, width) {
var self = Container.call(this);
var groundGraphics = self.attachAsset('ground', {
anchorX: 0,
anchorY: 0
});
groundGraphics.width = width || 200;
self.x = x;
self.y = y;
return self;
});
var LevelButton = Container.expand(function (levelNum, x, y) {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('levelButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.levelNum = levelNum;
self.x = x;
self.y = y;
self.locked = levelNum > 1 && !storage.completedLevels[levelNum - 1];
// Set button color based on status
if (self.locked) {
buttonGraphics.tint = 0x666666;
} else if (storage.completedLevels[levelNum]) {
buttonGraphics.tint = 0x00ff00;
}
// Level number text
self.levelText = new Text2(levelNum.toString(), {
size: 40,
fill: 0xFFFFFF
});
self.levelText.anchor.set(0.5, 0.3);
self.addChild(self.levelText);
// Coin count text
var coinCount = storage.levelCoins[levelNum] || 0;
var maxCoins = levelData[levelNum] ? levelData[levelNum].coins.length : 0;
self.coinText = new Text2(coinCount + '/' + maxCoins, {
size: 25,
fill: 0xFFD700
});
self.coinText.anchor.set(0.5, 0.7);
self.addChild(self.coinText);
self.down = function (x, y, obj) {
if (!self.locked) {
currentLevel = self.levelNum;
showGameplay();
}
};
return self;
});
var Platform = Container.expand(function (x, y, width) {
var self = Container.call(this);
var platformGraphics = self.attachAsset('platform', {
anchorX: 0,
anchorY: 0
});
platformGraphics.width = width || 200;
self.x = x;
self.y = y;
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
self.isShipMode = false;
self.playerGraphics = null;
self.shipGraphics = null;
self.setMode = function (isShip) {
if (self.playerGraphics) {
self.removeChild(self.playerGraphics);
self.playerGraphics = null;
}
if (self.shipGraphics) {
self.removeChild(self.shipGraphics);
self.shipGraphics = null;
}
self.isShipMode = isShip;
if (isShip) {
self.shipGraphics = self.attachAsset('ship', {
anchorX: 0.5,
anchorY: 0.5
});
} else {
self.playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
}
};
// Initialize with player mode
self.setMode(false);
self.velocityY = 0;
self.isGrounded = false;
self.isDead = false;
self.isFlying = false;
self.isSwinging = false;
self.swingAnchor = null;
self.swingAngle = 0;
self.swingLength = 0;
self.swingSpeed = 0;
self.jump = function () {
if (self.isShipMode) {
if (!self.isDead) {
self.isFlying = true;
self.velocityY = -12;
LK.getSound('jump').play();
}
} else {
if (self.isGrounded && !self.isDead) {
self.velocityY = -24;
self.isGrounded = false;
LK.getSound('jump').play();
}
}
};
self.stopJump = function () {
if (self.isShipMode) {
self.isFlying = false;
} else if (self.isSwinging) {
// Release from swing
var releaseVelX = Math.cos(self.swingAngle + Math.PI / 2) * self.swingSpeed * 0.8;
var releaseVelY = Math.sin(self.swingAngle + Math.PI / 2) * self.swingSpeed * 0.8;
self.velocityY = releaseVelY;
self.releaseVelX = releaseVelX;
self.isSwinging = false;
if (self.swingAnchor) {
self.swingAnchor.deactivateSwing();
self.swingAnchor = null;
}
}
};
self.update = function () {
if (self.isDead) return;
if (self.isSwinging) {
// Swing physics
var gravity = 0.8;
var dampening = 0.995;
// Apply gravity to swing speed
var gravityForce = gravity * Math.cos(self.swingAngle);
self.swingSpeed += gravityForce;
self.swingSpeed *= dampening;
// Update swing angle
self.swingAngle += self.swingSpeed / self.swingLength;
// Update player position based on swing
self.x = self.swingAnchor.x + Math.cos(self.swingAngle) * self.swingLength;
self.y = self.swingAnchor.y + Math.sin(self.swingAngle) * self.swingLength;
// Update rope visual if exists
if (self.swingAnchor.rope) {
self.swingAnchor.rope.rotation = self.swingAngle;
}
} else if (self.isShipMode) {
// Ship mode physics
if (self.isFlying) {
self.velocityY -= 2.5;
} else {
self.velocityY += 2.0;
}
// Limit ship velocity
if (self.velocityY > 18) self.velocityY = 18;
if (self.velocityY < -18) self.velocityY = -18;
self.y += self.velocityY;
// Ship ground collision
if (self.y >= groundLevel - 20) {
self.y = groundLevel - 20;
self.velocityY = 0;
}
// Ship ceiling collision
if (self.y <= 100) {
self.y = 100;
self.velocityY = 0;
}
} else {
// Regular cube mode physics
if (self.releaseVelX) {
// Apply horizontal velocity from swing release
self.x += self.releaseVelX;
self.releaseVelX *= 0.95; // Decay horizontal velocity
if (Math.abs(self.releaseVelX) < 0.5) {
self.releaseVelX = 0;
}
}
self.velocityY += 2.0;
self.y += self.velocityY;
// Ground collision
if (self.y >= groundLevel) {
self.y = groundLevel;
self.velocityY = 0;
self.isGrounded = true;
self.releaseVelX = 0; // Stop horizontal movement on ground
}
}
};
return self;
});
var Spike = Container.expand(function (x, y) {
var self = Container.call(this);
var spikeGraphics = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1.0
});
self.x = x;
self.y = y;
return self;
});
var SwingAnchor = Container.expand(function (x, y) {
var self = Container.call(this);
var anchorGraphics = self.attachAsset('swingAnchor', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.isActive = false;
self.rope = null;
self.activateSwing = function (player) {
if (!self.isActive && !player.isSwinging) {
self.isActive = true;
player.isSwinging = true;
player.swingAnchor = self;
player.swingAngle = Math.atan2(player.y - self.y, player.x - self.x);
player.swingLength = Math.sqrt(Math.pow(player.x - self.x, 2) + Math.pow(player.y - self.y, 2));
player.swingSpeed = 0;
// Create visual rope
self.rope = LK.getAsset('ground', {
anchorX: 0,
anchorY: 0.5
});
self.rope.width = player.swingLength;
self.rope.height = 4;
self.rope.tint = 0x8B4513;
self.rope.x = self.x;
self.rope.y = self.y;
self.rope.rotation = self.swingAngle;
game.addChild(self.rope);
// Animate anchor activation
tween(anchorGraphics, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
easing: tween.bounceOut
});
}
};
self.deactivateSwing = function () {
self.isActive = false;
if (self.rope) {
game.removeChild(self.rope);
self.rope = null;
}
tween(anchorGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222222
});
/****
* Game Code
****/
// Game states
var gameState = 'menu'; // 'menu' or 'playing'
var currentLevel = 1;
var maxLevels = 51;
var groundLevel = 2400;
var cameraX = 0;
var scrollSpeed = 12;
// Player variables
var player;
var playerStartX = 300;
var playerStartY = groundLevel;
// Level data
var obstacles = [];
var platforms = [];
var grounds = [];
var checkpoints = [];
var swingAnchors = [];
var coins = [];
var currentCheckpoint = 0;
var levelData = {};
// UI elements
var levelButtons = [];
var backButton;
var levelCompleteText;
var deathCount = 0;
// Storage initialization
if (!storage.completedLevels) {
storage.completedLevels = {};
}
if (!storage.currentLevel) {
storage.currentLevel = 1;
}
if (!storage.totalCoins) {
storage.totalCoins = 0;
}
if (!storage.levelCoins) {
storage.levelCoins = {};
}
// Initialize level data with unique patterns for each level
function initializeLevelData() {
for (var i = 1; i <= 51; i++) {
levelData[i] = {
spikes: [],
platforms: [],
checkpoints: [],
swingAnchors: [],
coins: [],
length: 2500 + i * 150,
shipMode: false
};
// Define unique patterns for each level
if (i === 1) {
// Level 1: Ship mode tutorial - simple gaps
levelData[i].shipMode = true;
levelData[i].length = 2000;
for (var s = 0; s < 3; s++) {
levelData[i].spikes.push({
x: 1000 + s * 600,
y: groundLevel
});
levelData[i].spikes.push({
x: 1000 + s * 600,
y: groundLevel - 300
});
// Add coins between spikes
if (s < 2) {
levelData[i].coins.push({
x: 1300 + s * 600,
y: groundLevel - 150
});
}
}
} else if (i === 2) {
// Level 2: Single spike jumps
for (var s = 0; s < 4; s++) {
levelData[i].spikes.push({
x: 800 + s * 400,
y: groundLevel
});
// Add coin above each spike
levelData[i].coins.push({
x: 800 + s * 400,
y: groundLevel - 100
});
}
} else if (i === 3) {
// Level 3: Double spike jumps
for (var s = 0; s < 3; s++) {
levelData[i].spikes.push({
x: 800 + s * 500,
y: groundLevel
});
levelData[i].spikes.push({
x: 840 + s * 500,
y: groundLevel
});
}
} else if (i === 4) {
// Level 4: Platform jumps with swing anchors
for (var p = 0; p < 4; p++) {
levelData[i].platforms.push({
x: 800 + p * 400,
y: groundLevel - 120,
width: 150
});
levelData[i].spikes.push({
x: 975 + p * 400,
y: groundLevel - 120
});
// Add swing anchor between platforms
if (p < 3) {
levelData[i].swingAnchors.push({
x: 1075 + p * 400,
y: groundLevel - 200
});
}
}
} else if (i === 5) {
// Level 5: Spike clusters
for (var c = 0; c < 3; c++) {
for (var s = 0; s < 3; s++) {
levelData[i].spikes.push({
x: 800 + c * 600 + s * 50,
y: groundLevel
});
}
// Add coin above each cluster
levelData[i].coins.push({
x: 850 + c * 600,
y: groundLevel - 120
});
}
} else if (i >= 6 && i <= 10) {
// Levels 6-10: Mixed patterns with increasing difficulty
var patternType = (i - 6) % 3;
if (patternType === 0) {
// Alternating single and double spikes
for (var s = 0; s < 5; s++) {
levelData[i].spikes.push({
x: 700 + s * 350,
y: groundLevel
});
if (s % 2 === 1) {
levelData[i].spikes.push({
x: 740 + s * 350,
y: groundLevel
});
}
// Add coins between spikes
if (s < 4) {
levelData[i].coins.push({
x: 875 + s * 350,
y: groundLevel - 80
});
}
}
} else if (patternType === 1) {
// Platform hopping
for (var p = 0; p < 4; p++) {
var height = groundLevel - 100 - p % 2 * 80;
levelData[i].platforms.push({
x: 800 + p * 350,
y: height,
width: 120
});
levelData[i].spikes.push({
x: 920 + p * 350,
y: height
});
}
} else {
// Triple spike jumps
for (var t = 0; t < 3; t++) {
for (var s = 0; s < 3; s++) {
levelData[i].spikes.push({
x: 800 + t * 500 + s * 45,
y: groundLevel
});
}
}
}
} else if (i >= 11 && i <= 20) {
// Levels 11-20: Advanced patterns
var complexity = i - 10;
if (i % 4 === 1) {
// Staircase platforms with spikes
for (var st = 0; st < 5; st++) {
var stairY = groundLevel - st * 60;
levelData[i].platforms.push({
x: 700 + st * 300,
y: stairY,
width: 150
});
levelData[i].spikes.push({
x: 850 + st * 300,
y: stairY
});
}
} else if (i % 4 === 2) {
// Ship mode level
levelData[i].shipMode = true;
for (var s = 0; s < 6; s++) {
levelData[i].spikes.push({
x: 800 + s * 300,
y: groundLevel
});
levelData[i].spikes.push({
x: 800 + s * 300,
y: groundLevel - 250
});
}
} else if (i % 4 === 3) {
// Maze-like platforms with swing challenges
for (var m = 0; m < 4; m++) {
var upper = m % 2 === 0;
var platY = upper ? groundLevel - 200 : groundLevel - 100;
levelData[i].platforms.push({
x: 700 + m * 400,
y: platY,
width: 200
});
levelData[i].spikes.push({
x: 800 + m * 400,
y: platY
});
// Add swing anchors for advanced navigation
if (m < 3) {
levelData[i].swingAnchors.push({
x: 900 + m * 400,
y: groundLevel - 300
});
}
}
} else {
// Rapid fire spikes
for (var r = 0; r < 8; r++) {
levelData[i].spikes.push({
x: 700 + r * 200,
y: groundLevel
});
}
}
} else if (i >= 21 && i <= 35) {
// Levels 21-35: Expert patterns
if (i % 5 === 1) {
// Multi-level platforms
for (var ml = 0; ml < 3; ml++) {
for (var level = 0; level < 3; level++) {
var platY = groundLevel - 80 - level * 70;
levelData[i].platforms.push({
x: 700 + ml * 500 + level * 100,
y: platY,
width: 100
});
if (level < 2) {
levelData[i].spikes.push({
x: 750 + ml * 500 + level * 100,
y: platY
});
}
}
// Add challenging coin placement
levelData[i].coins.push({
x: 850 + ml * 500,
y: groundLevel - 250
});
}
} else if (i % 5 === 2) {
// Ship maze
levelData[i].shipMode = true;
for (var sm = 0; sm < 5; sm++) {
levelData[i].spikes.push({
x: 800 + sm * 250,
y: groundLevel
});
levelData[i].spikes.push({
x: 825 + sm * 250,
y: groundLevel - 150
});
levelData[i].spikes.push({
x: 850 + sm * 250,
y: groundLevel - 300
});
}
} else if (i % 5 === 3) {
// Wave pattern spikes
for (var w = 0; w < 8; w++) {
var wave = Math.sin(w * 0.8) * 100;
levelData[i].spikes.push({
x: 700 + w * 150,
y: groundLevel + wave
});
}
} else if (i % 5 === 4) {
// Tight platform sequences
for (var tp = 0; tp < 6; tp++) {
levelData[i].platforms.push({
x: 700 + tp * 250,
y: groundLevel - 120,
width: 80
});
levelData[i].spikes.push({
x: 780 + tp * 250,
y: groundLevel - 120
});
levelData[i].spikes.push({
x: 950 + tp * 250,
y: groundLevel
});
}
} else {
// Spike walls
for (var sw = 0; sw < 4; sw++) {
for (var wall = 0; wall < 4; wall++) {
levelData[i].spikes.push({
x: 800 + sw * 400,
y: groundLevel - wall * 50
});
}
}
}
} else {
// Levels 36-50: Master difficulty
var masterPattern = (i - 35) % 8;
if (masterPattern === 0) {
// Ultimate ship challenge
levelData[i].shipMode = true;
for (var uc = 0; uc < 10; uc++) {
levelData[i].spikes.push({
x: 600 + uc * 180,
y: groundLevel
});
levelData[i].spikes.push({
x: 620 + uc * 180,
y: groundLevel - 100
});
levelData[i].spikes.push({
x: 640 + uc * 180,
y: groundLevel - 200
});
levelData[i].spikes.push({
x: 660 + uc * 180,
y: groundLevel - 300
});
// Add very challenging coins
if (uc % 3 === 0) {
levelData[i].coins.push({
x: 630 + uc * 180,
y: groundLevel - 150
});
}
}
} else if (masterPattern === 1) {
// Precision platform jumps
for (var pp = 0; pp < 8; pp++) {
levelData[i].platforms.push({
x: 700 + pp * 200,
y: groundLevel - 60 - pp % 3 * 40,
width: 60
});
levelData[i].spikes.push({
x: 730 + pp * 200,
y: groundLevel - 60 - pp % 3 * 40
});
}
} else if (masterPattern === 2) {
// Chaos mode - random but beatable
for (var ch = 0; ch < 12; ch++) {
if (ch % 3 === 0) {
levelData[i].platforms.push({
x: 600 + ch * 150,
y: groundLevel - 100,
width: 100
});
} else {
levelData[i].spikes.push({
x: 600 + ch * 150,
y: groundLevel
});
}
}
} else if (masterPattern === 3) {
// Double layer platforms
for (var dl = 0; dl < 5; dl++) {
levelData[i].platforms.push({
x: 700 + dl * 300,
y: groundLevel - 100,
width: 120
});
levelData[i].platforms.push({
x: 760 + dl * 300,
y: groundLevel - 180,
width: 120
});
levelData[i].spikes.push({
x: 820 + dl * 300,
y: groundLevel - 100
});
levelData[i].spikes.push({
x: 880 + dl * 300,
y: groundLevel - 180
});
}
} else if (masterPattern === 4) {
// Speed run spikes
for (var sr = 0; sr < 15; sr++) {
levelData[i].spikes.push({
x: 600 + sr * 120,
y: groundLevel
});
if (sr % 3 === 2) {
levelData[i].spikes.push({
x: 620 + sr * 120,
y: groundLevel
});
}
}
} else if (masterPattern === 5) {
// Alternating ship/cube sections
if (i % 2 === 0) {
levelData[i].shipMode = true;
}
for (var as = 0; as < 8; as++) {
levelData[i].spikes.push({
x: 700 + as * 200,
y: groundLevel
});
if (levelData[i].shipMode) {
levelData[i].spikes.push({
x: 720 + as * 200,
y: groundLevel - 200
});
}
}
} else if (masterPattern === 6) {
// Extreme precision
for (var ep = 0; ep < 6; ep++) {
levelData[i].platforms.push({
x: 700 + ep * 250,
y: groundLevel - 90,
width: 50
});
levelData[i].spikes.push({
x: 725 + ep * 250,
y: groundLevel - 90
});
levelData[i].spikes.push({
x: 750 + ep * 250,
y: groundLevel - 90
});
levelData[i].spikes.push({
x: 950 + ep * 250,
y: groundLevel
});
}
} else {
// Final boss level patterns
for (var fb = 0; fb < 5; fb++) {
// Complex multi-height obstacles
for (var h = 0; h < 4; h++) {
if ((fb + h) % 2 === 0) {
levelData[i].spikes.push({
x: 700 + fb * 300 + h * 40,
y: groundLevel - h * 60
});
} else {
levelData[i].platforms.push({
x: 700 + fb * 300 + h * 40,
y: groundLevel - h * 60,
width: 80
});
}
}
}
}
}
// Special level 51 pattern with starting swing
if (i === 51) {
// Start with a swing anchor at the beginning
levelData[i].swingAnchors.push({
x: 500,
y: groundLevel - 150
});
// Add platform to swing to
levelData[i].platforms.push({
x: 700,
y: groundLevel - 100,
width: 120
});
// Add spikes after platform
for (var s51 = 0; s51 < 5; s51++) {
levelData[i].spikes.push({
x: 900 + s51 * 200,
y: groundLevel
});
}
// Add more swing anchors throughout level
levelData[i].swingAnchors.push({
x: 1200,
y: groundLevel - 200
});
levelData[i].swingAnchors.push({
x: 1600,
y: groundLevel - 180
});
// Add challenging platform sequence
for (var p51 = 0; p51 < 4; p51++) {
levelData[i].platforms.push({
x: 1800 + p51 * 300,
y: groundLevel - 120 - p51 % 2 * 60,
width: 100
});
levelData[i].spikes.push({
x: 1850 + p51 * 300,
y: groundLevel - 120 - p51 % 2 * 60
});
}
}
// Add default coins if none were added yet
if (levelData[i].coins.length === 0) {
var coinCount = Math.max(2, Math.floor(i / 5) + 1);
for (var c = 0; c < coinCount; c++) {
levelData[i].coins.push({
x: 600 + c * (levelData[i].length / (coinCount + 1)),
y: groundLevel - 80 - c % 3 * 40
});
}
}
// Add checkpoints based on level length
var checkpointCount = Math.max(1, Math.floor(levelData[i].length / 800));
for (var k = 1; k <= checkpointCount; k++) {
levelData[i].checkpoints.push({
x: k * (levelData[i].length / (checkpointCount + 1)),
y: groundLevel
});
}
}
}
// UI Setup
function setupUI() {
// Score display
var scoreText = new Text2('Level: ' + currentLevel, {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
scoreText.x = 120;
scoreText.y = 50;
LK.gui.topLeft.addChild(scoreText);
// Coin counter
var coinText = new Text2('Coins: ' + storage.totalCoins, {
size: 50,
fill: 0xFFD700
});
coinText.anchor.set(0, 0);
coinText.x = 120;
coinText.y = 120;
LK.gui.topLeft.addChild(coinText);
}
// Level selection menu
function showLevelMenu() {
gameState = 'menu';
game.removeChildren();
levelButtons = [];
// Title
var titleText = new Text2('Geometry Dash: 50 Levels', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 200;
game.addChild(titleText);
// Create level buttons in grid
var buttonsPerRow = 5;
var buttonSpacing = 220;
var startX = 1024 - (buttonsPerRow - 1) * buttonSpacing / 2;
var startY = 400;
for (var i = 1; i <= maxLevels; i++) {
var row = Math.floor((i - 1) / buttonsPerRow);
var col = (i - 1) % buttonsPerRow;
var buttonX = startX + col * buttonSpacing;
var buttonY = startY + row * 150;
var levelBtn = game.addChild(new LevelButton(i, buttonX, buttonY));
levelButtons.push(levelBtn);
}
// Video button
var videoButton = LK.getAsset('levelButton', {
anchorX: 0.5,
anchorY: 0.5
});
videoButton.x = 1024;
videoButton.y = startY + Math.ceil(maxLevels / buttonsPerRow) * 150 + 100;
videoButton.tint = 0x9933ff;
game.addChild(videoButton);
var videoText = new Text2('Video', {
size: 40,
fill: 0xFFFFFF
});
videoText.anchor.set(0.5, 0.5);
videoText.x = videoButton.x;
videoText.y = videoButton.y;
game.addChild(videoText);
videoButton.down = function (x, y, obj) {
showVideoTutorial();
};
// Owner commands button
var ownerButton = LK.getAsset('levelButton', {
anchorX: 0.5,
anchorY: 0.5
});
ownerButton.x = 1024;
ownerButton.y = startY + Math.ceil(maxLevels / buttonsPerRow) * 150 + 250;
ownerButton.tint = 0xffaa00;
game.addChild(ownerButton);
var ownerText = new Text2('Owner', {
size: 40,
fill: 0xFFFFFF
});
ownerText.anchor.set(0.5, 0.5);
ownerText.x = ownerButton.x;
ownerText.y = ownerButton.y;
game.addChild(ownerText);
ownerButton.down = function (x, y, obj) {
showOwnerCommands();
};
}
// Show gameplay
function showGameplay() {
gameState = 'playing';
game.removeChildren();
// Reset camera
cameraX = 0;
currentCheckpoint = 0;
deathCount = 0;
// Create player
player = game.addChild(new Player());
player.x = playerStartX;
player.y = playerStartY;
// Set ship mode based on level data
if (levelData[currentLevel].shipMode) {
player.setMode(true);
player.y = groundLevel - 200; // Start ship higher up
} else {
player.setMode(false);
}
// Load current level
loadLevel(currentLevel);
}
// Load level obstacles
function loadLevel(levelNum) {
obstacles = [];
platforms = [];
grounds = [];
checkpoints = [];
swingAnchors = [];
coins = [];
var level = levelData[levelNum];
// Create ground segments
for (var x = 0; x <= level.length + 1000; x += 200) {
var ground = game.addChild(new Ground(x, groundLevel, 200));
grounds.push(ground);
}
// Create spikes
for (var i = 0; i < level.spikes.length; i++) {
var spikeData = level.spikes[i];
var spike = game.addChild(new Spike(spikeData.x, spikeData.y));
obstacles.push(spike);
}
// Create platforms
for (var j = 0; j < level.platforms.length; j++) {
var platformData = level.platforms[j];
var platform = game.addChild(new Platform(platformData.x, platformData.y, platformData.width));
platforms.push(platform);
}
// Create checkpoints
for (var k = 0; k < level.checkpoints.length; k++) {
var checkpointData = level.checkpoints[k];
var checkpoint = game.addChild(new Checkpoint(checkpointData.x, checkpointData.y));
checkpoints.push(checkpoint);
}
// Create swing anchors
for (var s = 0; s < level.swingAnchors.length; s++) {
var anchorData = level.swingAnchors[s];
var swingAnchor = game.addChild(new SwingAnchor(anchorData.x, anchorData.y));
swingAnchors.push(swingAnchor);
}
// Create coins
for (var c = 0; c < level.coins.length; c++) {
var coinData = level.coins[c];
var coin = game.addChild(new Coin(coinData.x, coinData.y));
coins.push(coin);
}
}
// Handle player death
function handlePlayerDeath() {
if (player.isDead) return;
player.isDead = true;
deathCount++;
LK.effects.flashScreen(0xff0000, 500);
LK.getSound('death').play();
// Respawn after delay
LK.setTimeout(function () {
respawnPlayer();
}, 1000);
}
// Respawn player at checkpoint
function respawnPlayer() {
player.isDead = false;
player.velocityY = 0;
player.isGrounded = false;
if (currentCheckpoint > 0 && checkpoints[currentCheckpoint - 1]) {
player.x = checkpoints[currentCheckpoint - 1].x;
cameraX = checkpoints[currentCheckpoint - 1].x - 400;
} else {
player.x = playerStartX;
cameraX = 0;
}
player.y = groundLevel;
}
// Handle level completion
function completeLevel() {
storage.completedLevels[currentLevel] = true;
LK.getSound('complete').play();
LK.effects.flashScreen(0x00ff00, 1000);
// Show completion message
var completeText = new Text2('Level Complete!', {
size: 100,
fill: 0x00FF00
});
completeText.anchor.set(0.5, 0.5);
completeText.x = 1024;
completeText.y = 1366;
game.addChild(completeText);
// Return to menu after delay
LK.setTimeout(function () {
showLevelMenu();
}, 2000);
}
// Input handling
game.down = function (x, y, obj) {
if (gameState === 'playing' && player && !player.isDead) {
player.jump();
}
};
game.up = function (x, y, obj) {
if (gameState === 'playing' && player && !player.isDead) {
player.stopJump();
}
};
// Main game loop
game.update = function () {
if (gameState !== 'playing' || !player || player.isDead) return;
// Auto-scroll camera
cameraX += scrollSpeed;
player.x += scrollSpeed;
// Update camera position
var targetCameraX = player.x - 400;
if (targetCameraX > cameraX) {
cameraX = targetCameraX;
}
// Position all game objects relative to camera
game.x = -cameraX;
// Check obstacle collisions
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
if (player.intersects(obstacle)) {
handlePlayerDeath();
break;
}
}
// Check platform collisions (simple top collision)
for (var j = 0; j < platforms.length; j++) {
var platform = platforms[j];
if (player.intersects(platform) && player.velocityY > 0) {
var playerBottom = player.y;
var platformTop = platform.y;
if (playerBottom >= platformTop && playerBottom <= platformTop + 20) {
player.y = platformTop;
player.velocityY = 0;
player.isGrounded = true;
}
}
}
// Check checkpoint activation
for (var k = 0; k < checkpoints.length; k++) {
var checkpoint = checkpoints[k];
if (!checkpoint.activated && player.intersects(checkpoint)) {
checkpoint.activated = true;
currentCheckpoint = k + 1;
LK.effects.flashObject(checkpoint, 0x00ffff, 500);
}
}
// Check swing anchor activation
for (var s = 0; s < swingAnchors.length; s++) {
var anchor = swingAnchors[s];
if (!anchor.isActive && !player.isSwinging && player.intersects(anchor)) {
var distance = Math.sqrt(Math.pow(player.x - anchor.x, 2) + Math.pow(player.y - anchor.y, 2));
if (distance < 80) {
// Activation range
anchor.activateSwing(player);
break;
}
}
}
// Check coin collection
for (var c = 0; c < coins.length; c++) {
var coin = coins[c];
if (!coin.collected && player.intersects(coin)) {
coin.collected = true;
coin.visible = false;
storage.totalCoins++;
// Update level-specific coin tracking
if (!storage.levelCoins[currentLevel]) {
storage.levelCoins[currentLevel] = 0;
}
storage.levelCoins[currentLevel]++;
// Play coin sound and visual effect
LK.getSound('coin').play();
LK.effects.flashObject(coin, 0xFFD700, 300);
// Update coin counter
var coinTexts = LK.gui.topLeft.children;
for (var t = 0; t < coinTexts.length; t++) {
if (coinTexts[t].text && coinTexts[t].text.indexOf('Coins:') === 0) {
coinTexts[t].setText('Coins: ' + storage.totalCoins);
break;
}
}
}
}
// Check level completion
var levelLength = levelData[currentLevel].length;
if (player.x >= levelLength) {
completeLevel();
}
// Check if player fell off screen
if (player.y > 2800) {
handlePlayerDeath();
}
};
// Video tutorial screen
function showVideoTutorial() {
gameState = 'video';
game.removeChildren();
// Title
var titleText = new Text2('How to Beat Geometry Dash', {
size: 70,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 150;
game.addChild(titleText);
// Instructions sections
var instructions = ['BASIC CONTROLS:', '• Tap/Click to jump in cube mode', '• Hold to fly up in ship mode', '• Release to fall down in ship mode', '', 'GAMEPLAY TIPS:', '• Red spikes = deadly obstacles', '• Gray platforms = safe to land on', '• Cyan checkpoints = save your progress', '• Green squares = completed levels', '', 'LEVEL PROGRESSION:', '• Levels 1-10: Learn basic mechanics', '• Levels 11-20: Master timing and ship mode', '• Levels 21-35: Expert precision required', '• Levels 36-50: Ultimate challenges', '', 'SURVIVAL STRATEGY:', '• Practice timing on easier levels first', '• Use checkpoints to avoid restarting', '• Ship levels require smooth control', '• Platform levels need precise jumps'];
var instructionY = 300;
var lineHeight = 45;
for (var i = 0; i < instructions.length; i++) {
var line = instructions[i];
var isHeader = line.endsWith(':');
var fontSize = isHeader ? 50 : 40;
var color = isHeader ? 0x00FF00 : 0xFFFFFF;
var instructionText = new Text2(line, {
size: fontSize,
fill: color
});
instructionText.anchor.set(0, 0);
instructionText.x = 200;
instructionY += line === '' ? lineHeight * 0.5 : lineHeight;
instructionText.y = instructionY;
game.addChild(instructionText);
}
// Demo visual elements
var demoY = 1800;
// Show cube example
var demoCube = LK.getAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
demoCube.x = 400;
demoCube.y = demoY;
game.addChild(demoCube);
var cubeLabel = new Text2('Cube Mode', {
size: 35,
fill: 0x00FF00
});
cubeLabel.anchor.set(0.5, 0);
cubeLabel.x = demoCube.x;
cubeLabel.y = demoY + 20;
game.addChild(cubeLabel);
// Show ship example
var demoShip = LK.getAsset('ship', {
anchorX: 0.5,
anchorY: 0.5
});
demoShip.x = 800;
demoShip.y = demoY - 30;
game.addChild(demoShip);
var shipLabel = new Text2('Ship Mode', {
size: 35,
fill: 0x0088FF
});
shipLabel.anchor.set(0.5, 0);
shipLabel.x = demoShip.x;
shipLabel.y = demoY + 20;
game.addChild(shipLabel);
// Show spike example
var demoSpike = LK.getAsset('spike', {
anchorX: 0.5,
anchorY: 1.0
});
demoSpike.x = 1200;
demoSpike.y = demoY;
game.addChild(demoSpike);
var spikeLabel = new Text2('Deadly Spike', {
size: 35,
fill: 0xFF0000
});
spikeLabel.anchor.set(0.5, 0);
spikeLabel.x = demoSpike.x;
spikeLabel.y = demoY + 20;
game.addChild(spikeLabel);
// Show platform example
var demoPlatform = LK.getAsset('platform', {
anchorX: 0,
anchorY: 0
});
demoPlatform.x = 1500;
demoPlatform.y = demoY - 40;
demoPlatform.width = 150;
game.addChild(demoPlatform);
var platformLabel = new Text2('Safe Platform', {
size: 35,
fill: 0x888888
});
platformLabel.anchor.set(0.5, 0);
platformLabel.x = demoPlatform.x + 75;
platformLabel.y = demoY + 20;
game.addChild(platformLabel);
// Animate demo elements
var animTime = 0;
var videoUpdateTimer = LK.setInterval(function () {
animTime += 0.1;
// Bounce cube
demoCube.y = demoY + Math.abs(Math.sin(animTime * 2)) * -30;
// Float ship
demoShip.y = demoY - 30 + Math.sin(animTime) * 15;
// Pulse spike
demoSpike.alpha = 0.7 + Math.sin(animTime * 3) * 0.3;
}, 50);
// Back button
var backButton = LK.getAsset('levelButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 2400;
backButton.tint = 0x666666;
game.addChild(backButton);
var backText = new Text2('Back to Menu', {
size: 40,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.x = backButton.x;
backText.y = backButton.y;
game.addChild(backText);
backButton.down = function (x, y, obj) {
LK.clearInterval(videoUpdateTimer);
showLevelMenu();
};
}
// Owner commands screen
function showOwnerCommands() {
gameState = 'owner';
game.removeChildren();
// Title
var titleText = new Text2('Owner Commands', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 200;
game.addChild(titleText);
// Command buttons
var commandButtons = [{
text: 'Unlock All Levels',
action: unlockAllLevels
}, {
text: 'Reset Progress',
action: resetProgress
}, {
text: 'Complete All Levels',
action: completeAllLevels
}, {
text: 'Back to Menu',
action: showLevelMenu
}];
var buttonY = 400;
for (var i = 0; i < commandButtons.length; i++) {
var cmdButton = LK.getAsset('levelButton', {
anchorX: 0.5,
anchorY: 0.5
});
cmdButton.x = 1024;
cmdButton.y = buttonY + i * 150;
cmdButton.tint = 0x444444;
game.addChild(cmdButton);
var cmdText = new Text2(commandButtons[i].text, {
size: 35,
fill: 0xFFFFFF
});
cmdText.anchor.set(0.5, 0.5);
cmdText.x = cmdButton.x;
cmdText.y = cmdButton.y;
game.addChild(cmdText);
cmdButton.commandAction = commandButtons[i].action;
cmdButton.down = function (x, y, obj) {
this.commandAction();
};
}
}
// Owner command functions
function unlockAllLevels() {
for (var i = 1; i <= maxLevels; i++) {
storage.completedLevels[i] = false; // Unlocked but not completed
}
showLevelMenu();
}
function resetProgress() {
storage.completedLevels = {};
showLevelMenu();
}
function completeAllLevels() {
for (var i = 1; i <= maxLevels; i++) {
storage.completedLevels[i] = true;
}
showLevelMenu();
}
// Initialize game
initializeLevelData();
setupUI();
showLevelMenu(); ===================================================================
--- original.js
+++ change.js
@@ -307,9 +307,9 @@
****/
// Game states
var gameState = 'menu'; // 'menu' or 'playing'
var currentLevel = 1;
-var maxLevels = 50;
+var maxLevels = 51;
var groundLevel = 2400;
var cameraX = 0;
var scrollSpeed = 12;
// Player variables
@@ -344,9 +344,9 @@
storage.levelCoins = {};
}
// Initialize level data with unique patterns for each level
function initializeLevelData() {
- for (var i = 1; i <= maxLevels; i++) {
+ for (var i = 1; i <= 51; i++) {
levelData[i] = {
spikes: [],
platforms: [],
checkpoints: [],
@@ -780,8 +780,50 @@
}
}
}
}
+ // Special level 51 pattern with starting swing
+ if (i === 51) {
+ // Start with a swing anchor at the beginning
+ levelData[i].swingAnchors.push({
+ x: 500,
+ y: groundLevel - 150
+ });
+ // Add platform to swing to
+ levelData[i].platforms.push({
+ x: 700,
+ y: groundLevel - 100,
+ width: 120
+ });
+ // Add spikes after platform
+ for (var s51 = 0; s51 < 5; s51++) {
+ levelData[i].spikes.push({
+ x: 900 + s51 * 200,
+ y: groundLevel
+ });
+ }
+ // Add more swing anchors throughout level
+ levelData[i].swingAnchors.push({
+ x: 1200,
+ y: groundLevel - 200
+ });
+ levelData[i].swingAnchors.push({
+ x: 1600,
+ y: groundLevel - 180
+ });
+ // Add challenging platform sequence
+ for (var p51 = 0; p51 < 4; p51++) {
+ levelData[i].platforms.push({
+ x: 1800 + p51 * 300,
+ y: groundLevel - 120 - p51 % 2 * 60,
+ width: 100
+ });
+ levelData[i].spikes.push({
+ x: 1850 + p51 * 300,
+ y: groundLevel - 120 - p51 % 2 * 60
+ });
+ }
+ }
// Add default coins if none were added yet
if (levelData[i].coins.length === 0) {
var coinCount = Math.max(2, Math.floor(i / 5) + 1);
for (var c = 0; c < coinCount; c++) {