User prompt
Create the sound effect asset, Landing Swamp, and the music asset, Ambience Swamp.
User prompt
Make it so that only in the jungle map the player is a bit Lowered into the ground making it seem like there are they are stuck in the mud Create a sound called out of mud landing swamp and
User prompt
create me a new area in the map selection called swamp, create new obstacles, lily pad, create new ground, swamp ground, and create new background, swamp background, also create
User prompt
delete the background sky asset and create a new obstacle tree trunk which is now the obstacle of the jungle map replacing the current one so that it does not have the same obstacle as the beach map
User prompt
Create a new obstacle called JungleLog and make the JungleLog obstacle now be the obstacle of the jungle.
User prompt
20 points, it does not get any faster but still gets difficulter but ever so slightly more
User prompt
When the player ranks up to any of the three ranks, bronze, silver or gold, only the sound for the respective rank will play and not the sound for score to make it easier on the ears.
User prompt
achievement pop-up for the name of the achievement, show the trophy icon that is also, well, the button for trophies and, well, for highscore and achievements.
User prompt
Rename the High Score button to High Scores and Achievements and make it so that you can scroll down in that menu and below the High Score you can now see all Achievements you've earned.
User prompt
Make the achievement pop up white with black text and show the achievement name Also create a new achievement called Explorer where the player has to manage one jump on every map
User prompt
Make sure that during the data clearing animation the player cannot press any buttons.
User prompt
Make sure that during data-clearing animation, the player cannot press any buttons.
User prompt
Make it so when touching the laser walls, just like the lava geysers, the player turns into a pile of ash. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
animation cycle for the lasers way faster and make it so that if the player collides with those laser walls instead of the usual red flash the screen flashes turquoise and they, like the lava geyser, get turned into the ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Change the format for background space to be the same format as all the other backgrounds of the other maps. Also create a sound, landing space, used for the landing sound effect on the space map.
User prompt
Make it so that all laser wall elements from 1 to 4 alternate randomly on the same object to make an animation. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
new map to the map selection, use the already existing space elements for this map and call the map space.
User prompt
that the ambience when turned on also plays when playing a map. So make sure that works on standard even after resetting all data. Also make sure during the reset all data animation you cannot press anything.
User prompt
Make sure that the background for menus just darkens everything and not turns everything into a specific color. But just darken the background and everything except for the UI elements.
User prompt
Okay, I can not see the background loading in anymore, except for the first time. The first time it does not work. So make the first background scroll slower than all the rest of the backgrounds, but make them get progressively faster so it doesn't seem weird. Also create the sound... ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make sure that the background is just two images. Well both times the same background element but scrolling and then repeating itself so that nobody can see it generating and have a black box. Also fix an issue that the
User prompt
for some reason as soon as I well as soon as the first background is over I see a black screen for the second background but then the looping works properly also make the space background button as wide as the other
User prompt
Fix an issue where the first background would be visible generating by when the player reached it.
User prompt
Make sure that the player cannot see the first backgrounds being generated. Also make sure the volcano map is still available and visible.
User prompt
Make a button next to the volcano map in the map select and make it the space map.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
musicEnabled: false,
ambienceEnabled: true
});
/****
* Classes
****/
var JungleTreeTrunk = Container.expand(function () {
var self = Container.call(this);
self.speed = -24;
self.passed = false;
// Create jungle tree trunk graphics with standardized size
var trunkGraphics = self.attachAsset('palmTree', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 2.5,
scaleY: 2.5,
tint: 0x8B4513 // Brown color to make it look like a tree trunk
});
// Store graphics reference
self.trunkGraphics = trunkGraphics;
// Set standardized obstacle dimensions - 300x400 pixels
self.width = 300;
self.height = 400;
self.update = function () {
self.x += self.speed;
// Add slight swaying animation like a standing tree trunk
self.trunkGraphics.rotation = Math.sin(LK.ticks * 0.02) * 0.03;
};
return self;
});
var LanguageButton = Container.expand(function (language, callback) {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.graphics = buttonGraphics;
var buttonText = new Text2(language, {
size: 120,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function () {
LK.getSound('Gear').play();
if (callback) callback();
};
return self;
});
var LaserWall = Container.expand(function (laserType) {
var self = Container.call(this);
self.speed = -24;
self.passed = false;
self.laserType = laserType || 'laser_wall';
self.pulseTimer = 0;
self.pulseInterval = 60; // Pulse every second at 60fps
self.isPulsing = false;
self.pulseDirection = 1;
self.pulseIntensity = 0.5;
// Available laser wall types for animation
self.laserTypes = ['laser_wall', 'laser_wall_2', 'laser_wall_3', 'laser_wall_4'];
self.currentTypeIndex = 0;
self.animationTimer = 0;
self.animationInterval = Math.floor(Math.random() * 10) + 5; // Random interval between 5-15 frames (much faster)
// Create laser wall graphics with standardized scaling
var laserGraphics = self.attachAsset(self.laserType, {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 3.0,
scaleY: 1.0
});
// Store graphics reference for later manipulation
self.laserGraphics = laserGraphics;
// Set standardized obstacle dimensions - 300x600 pixels
self.width = 300;
self.height = 600;
// Function to change laser wall type with animation
self.changeLaserType = function () {
// Get random new type different from current
var newTypeIndex;
do {
newTypeIndex = Math.floor(Math.random() * self.laserTypes.length);
} while (newTypeIndex === self.currentTypeIndex);
self.currentTypeIndex = newTypeIndex;
var newType = self.laserTypes[self.currentTypeIndex];
// Animate transition with tween
tween(self.laserGraphics, {
alpha: 0.2,
scaleX: 2.5
}, {
duration: 150,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Remove old graphics and create new
if (self.laserGraphics) {
self.removeChild(self.laserGraphics);
}
self.laserGraphics = self.attachAsset(newType, {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 2.5,
scaleY: 1.0,
alpha: 0.2
});
// Animate back to normal
tween(self.laserGraphics, {
alpha: self.pulseIntensity,
scaleX: 3.0
}, {
duration: 150,
easing: tween.easeInOut
});
}
});
// Set new random interval for next change
self.animationInterval = Math.floor(Math.random() * 10) + 5; // Much faster animation
self.animationTimer = 0;
};
self.update = function () {
self.x += self.speed;
// Handle laser type animation
self.animationTimer++;
if (self.animationTimer >= self.animationInterval) {
self.changeLaserType();
}
// Handle pulsing animation
self.pulseTimer++;
if (self.pulseTimer >= self.pulseInterval) {
self.isPulsing = !self.isPulsing;
self.pulseTimer = 0;
}
// Add pulsing glow effect
if (self.isPulsing) {
self.pulseIntensity += self.pulseDirection * 0.05;
if (self.pulseIntensity >= 1.0) {
self.pulseDirection = -1;
self.pulseIntensity = 1.0;
} else if (self.pulseIntensity <= 0.5) {
self.pulseDirection = 1;
self.pulseIntensity = 0.5;
}
if (self.laserGraphics) {
self.laserGraphics.alpha = self.pulseIntensity;
}
}
// Add slight vertical movement for dynamic feel
self.y += Math.sin(LK.ticks * 0.1) * 2;
};
return self;
});
var LavaGeyser = Container.expand(function () {
var self = Container.call(this);
self.speed = -24;
self.passed = false;
self.isErupting = false;
self.eruptionTimer = 0;
self.eruptionInterval = 120; // Erupts every 2 seconds at 60fps
self.eruptionDuration = 30; // Erupts for 0.5 seconds
// Create and attach the lava geyser graphics with standardized scaling
var geyserGraphics = self.attachAsset('lavaGeyser', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 3.0,
scaleY: 4.0
});
// Store graphics reference for later manipulation
self.geyserGraphics = geyserGraphics;
// Set standardized obstacle dimensions - 300x400 pixels
self.width = 300;
self.height = 400;
self.update = function () {
self.x += self.speed;
// Handle eruption timing
self.eruptionTimer++;
if (!self.isErupting && self.eruptionTimer >= self.eruptionInterval) {
self.isErupting = true;
self.eruptionTimer = 0;
// Make geyser glow bright red when erupting with pulsing effect
self.geyserGraphics.tint = 0xff2222;
self.geyserGraphics.alpha = 0.9 + Math.sin(LK.ticks * 0.5) * 0.1;
} else if (self.isErupting && self.eruptionTimer >= self.eruptionDuration) {
self.isErupting = false;
self.eruptionTimer = 0;
// Return to enhanced normal color for better visibility
self.geyserGraphics.tint = 0xffffff;
self.geyserGraphics.alpha = 1.0;
}
// Add slight vertical movement when erupting
if (self.isErupting) {
self.y += Math.sin(LK.ticks * 0.3) * 3;
}
};
return self;
});
var LilyPad = Container.expand(function () {
var self = Container.call(this);
self.speed = -24;
self.passed = false;
self.floatTimer = 0;
self.floatDirection = 1;
// Create lily pad graphics with standardized size
var lilyPadGraphics = self.attachAsset('lilyPad', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 0.75,
scaleY: 0.75
});
// Store graphics reference
self.lilyPadGraphics = lilyPadGraphics;
// Set standardized obstacle dimensions - 300x225 pixels
self.width = 300;
self.height = 225;
self.update = function () {
self.x += self.speed;
// Add gentle floating animation
self.floatTimer += 0.05;
self.y += Math.sin(self.floatTimer) * 0.8;
// Add subtle rotation like floating on water
self.lilyPadGraphics.rotation = Math.sin(self.floatTimer * 0.7) * 0.02;
};
return self;
});
var MenuButton = Container.expand(function (text, callback) {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 120,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function () {
LK.getSound('Lever').play();
if (callback) callback();
};
return self;
});
var MusicButton = Container.expand(function (isEnabled, callback) {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.6
});
self.graphics = buttonGraphics;
self.enabled = isEnabled;
self.callback = callback;
var buttonText = new Text2('MUSIC: ' + (isEnabled ? 'AN' : 'AUS'), {
size: 80,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.text = buttonText;
// Update button appearance
self.updateAppearance = function () {
self.text.setText('MUSIC: ' + (self.enabled ? 'AN' : 'AUS'));
self.graphics.tint = self.enabled ? 0x90ee90 : 0x666666;
};
self.updateAppearance();
self.down = function () {
if (self.enabled) {
LK.getSound('Started').play();
} else {
LK.getSound('Lever').play();
}
self.enabled = !self.enabled;
self.updateAppearance();
if (self.callback) self.callback(self.enabled);
};
return self;
});
var PalmTree = Container.expand(function () {
var self = Container.call(this);
self.speed = -24;
self.passed = false;
// Create palm tree graphics with standardized size
var palmTreeGraphics = self.attachAsset('palmTree', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 3.0,
scaleY: 3.0
});
// Store graphics reference
self.palmTreeGraphics = palmTreeGraphics;
// Set standardized obstacle dimensions - 300x400 pixels
self.width = 300;
self.height = 400;
self.update = function () {
self.x += self.speed;
// Add subtle swaying animation
palmTreeGraphics.rotation = Math.sin(LK.ticks * 0.02) * 0.05;
};
return self;
});
var PileOfAsh = Container.expand(function () {
var self = Container.call(this);
// Create pile of ash graphics
var ashGraphics = self.attachAsset('pileOfAsh', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 2.0,
scaleY: 1.5
});
self.ashGraphics = ashGraphics;
self.creationTime = LK.ticks;
// Set dimensions
self.width = ashGraphics.width;
self.height = ashGraphics.height;
self.update = function () {
// Slowly fade out over time
var timeSinceCreation = LK.ticks - self.creationTime;
if (timeSinceCreation > 180) {
// 3 seconds at 60fps
self.ashGraphics.alpha = Math.max(0, 1 - (timeSinceCreation - 180) / 120);
}
// Add slight wind effect
self.ashGraphics.x += Math.sin(LK.ticks * 0.02) * 0.5;
};
return self;
});
var SkinButton = Container.expand(function (skinType, callback) {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('skinButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.graphics = buttonGraphics;
var skinPreview = self.attachAsset(skinType, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
self.down = function () {
LK.getSound('Lever').play();
if (callback) callback();
};
return self;
});
var Turtle = Container.expand(function () {
var self = Container.call(this);
self.skinType = 'turtle_default';
self.originalSkin = 'turtle_default';
self.isJumping = false;
self.jumpSpeed = 0;
self.groundY = 0;
self.gravity = 2.4;
self.jumpPower = -90;
self.graphics = null;
self.setSkin = function (skinType) {
if (self.graphics) {
self.removeChild(self.graphics);
}
self.skinType = skinType;
self.originalSkin = skinType;
self.graphics = self.attachAsset(skinType, {
anchorX: 0.5,
anchorY: 1.0
});
// Set the container's dimensions to match the graphics
self.width = self.graphics.width;
self.height = self.graphics.height;
};
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.jumpSpeed = self.jumpPower;
LK.getSound('jump').play();
// Track jump for Explorer achievement
if (gameState === 'playing' && !hasJumpedOnMap[currentBackground]) {
hasJumpedOnMap[currentBackground] = true;
// Check if all maps have been jumped on
var allMapsJumped = true;
var mapKeys = ['background_beach', 'background_jungle', 'background_volcano', 'background_space', 'background_swamp'];
for (var i = 0; i < mapKeys.length; i++) {
if (!hasJumpedOnMap[mapKeys[i]]) {
allMapsJumped = false;
break;
}
}
if (allMapsJumped && !storage.explorerAchieved) {
storage.explorerAchieved = true;
showAchievementNotification("Explorer");
}
}
// Change skin when jumping
var jumpSkin = self.originalSkin;
if (self.originalSkin === 'turtle_default') {
jumpSkin = 'turtle_jump';
} else if (self.originalSkin === 'turtle_suit') {
jumpSkin = 'turtle_suit_jump';
} else if (self.originalSkin === 'turtle_red') {
jumpSkin = 'turtle_suit_jump';
} else if (self.originalSkin === 'turtle_golden') {
jumpSkin = 'turtle_golden_jump';
}
if (jumpSkin !== self.skinType) {
if (self.graphics) {
self.removeChild(self.graphics);
}
self.skinType = jumpSkin;
self.graphics = self.attachAsset(jumpSkin, {
anchorX: 0.5,
anchorY: 1.0
});
// Set the container's dimensions to match the graphics
self.width = self.graphics.width;
self.height = self.graphics.height;
}
}
};
self.update = function () {
if (self.isJumping) {
self.jumpSpeed += self.gravity;
self.y += self.jumpSpeed;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpSpeed = 0;
// Play landing sound based on current map
var landingSound = 'Land';
if (currentBackground === 'background_jungle') {
landingSound = 'out_of_mud_landing_swamp';
} else if (currentBackground === 'background_volcano') {
landingSound = 'landing_volcano';
} else if (currentBackground === 'background_space') {
landingSound = 'landing_space';
} else if (currentBackground === 'background_swamp') {
landingSound = 'landing_swamp';
}
LK.getSound(landingSound).play();
// Create dust particles
createDustParticles(self.x, self.y);
// Restore original skin when landing
if (self.skinType !== self.originalSkin) {
if (self.graphics) {
self.removeChild(self.graphics);
}
self.skinType = self.originalSkin;
self.graphics = self.attachAsset(self.originalSkin, {
anchorX: 0.5,
anchorY: 1.0
});
// Set the container's dimensions to match the graphics
self.width = self.graphics.width;
self.height = self.graphics.height;
}
}
}
};
return self;
});
var TurtleBack = Container.expand(function () {
var self = Container.call(this);
self.speed = -24;
self.collected = false;
var backGraphics = self.attachAsset('turtle_back', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 2.5
});
// Store graphics reference
self.backGraphics = backGraphics;
// Set standardized obstacle dimensions - 300x400 pixels
self.width = 300;
self.height = 400;
self.update = function () {
self.x += self.speed;
// Add floating animation
self.y += Math.sin(LK.ticks * 0.1) * 0.5;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game states
var gameState = 'menu'; // 'menu', 'playing', 'gameOver'
var gamePaused = false; // Controls whether game movement is paused
var darkOverlay = null; // Dark overlay for game over effect
var achievementContainer = null; // Container for achievement notifications
var currentSkin = storage.selectedSkin || 'turtle_default';
var currentLanguage = storage.selectedLanguage || 'English';
var languageMenuContainer = null;
var settingsMenuContainer = null;
var mapMenuContainer = null;
var highscoreWindowContainer = null;
var currentBackground = storage.selectedBackground || 'background_beach';
var backgroundElement = null;
var menuOverlay = null;
// Music settings
var musicEnabled = storage.musicEnabled;
var ambienceEnabled = storage.ambienceEnabled;
var musicVolume = storage.musicVolume || 0.5;
var currentMusicTrack = null;
// Language translations
var translations = {
English: {
title: 'Turtle Run',
play: 'PLAY',
skins: 'SKINS',
back: 'BACK',
chooseSkin: 'Choose Skin',
selectLanguage: 'Select Language',
highScore: 'High Score: '
},
Deutsch: {
title: 'Turtlerun',
play: 'SPIELEN',
skins: 'SKINS',
back: 'ZURÜCK',
chooseSkin: 'Skin auswählen',
selectLanguage: 'Sprache auswählen',
highScore: 'Highscore: '
}
};
// Function to get translated text
function getText(key) {
return translations[currentLanguage][key] || translations['English'][key];
}
// Game elements
var turtle = null;
var palmTrees = [];
var obstacles = [];
var turtleBacks = [];
var ground = null;
var scoreText = null;
var gameScore = 0;
var lastBoulderTime = 0;
var boulderInterval = 200; // milliseconds - much more frequent spawning
var minBoulderInterval = 40; // extremely aggressive minimum interval
var difficultyLevel = 1;
var speedMultiplier = 1.0;
// Achievement tracking
var hasJumpedOnMap = {
'background_beach': false,
'background_jungle': false,
'background_volcano': false,
'background_space': false,
'background_swamp': false
};
// Menu elements
var menuContainer = null;
var skinMenuContainer = null;
// Use stored background preference
currentBackground = storage.selectedBackground || 'background_beach';
var backgroundScrollSpeed = -12;
var backgroundElements = [];
// Create scrolling background system
function createScrollingBackground() {
// Create two background elements for seamless scrolling
for (var i = 0; i < 2; i++) {
var bg = game.addChild(LK.getAsset(currentBackground, {
anchorX: 0,
anchorY: 0,
x: i * 2048,
y: 0
}));
backgroundElements.push(bg);
}
}
// Initialize scrolling background
createScrollingBackground();
// Create menu overlay for better contrast
function createMenuOverlay() {
if (!menuOverlay) {
menuOverlay = game.addChild(LK.getAsset('background_sky', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
scaleX: 20.48,
scaleY: 27.32,
alpha: 0.5,
tint: 0x000000
}));
}
}
// Create dark overlay for game over effect
function createDarkOverlay() {
if (!darkOverlay) {
darkOverlay = game.addChild(LK.getAsset('background_sky', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
scaleX: 20.48,
scaleY: 27.32,
alpha: 0,
tint: 0x000000
}));
// Make sure it's on top of everything except UI
game.setChildIndex(darkOverlay, game.children.length - 1);
}
}
function showMenuOverlay() {
if (menuOverlay) {
menuOverlay.visible = true;
// Ensure overlay is above background but below menu elements
game.setChildIndex(menuOverlay, 2);
}
}
function hideMenuOverlay() {
if (menuOverlay) {
menuOverlay.visible = false;
}
}
// Initialize ground
function createGround() {
var groundAsset = 'ground';
if (currentBackground === 'background_jungle') {
groundAsset = 'ground_jungle';
} else if (currentBackground === 'background_volcano') {
groundAsset = 'ground_volcano';
} else if (currentBackground === 'background_space') {
groundAsset = 'ground_space';
} else if (currentBackground === 'background_swamp') {
groundAsset = 'ground_swamp';
}
return LK.getAsset(groundAsset, {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 270,
scaleY: 1.5
});
}
ground = game.addChild(createGround());
// Initialize score display
var initialScore = storage.currentScore || 0;
scoreText = new Text2(initialScore.toString(), {
size: 300,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreText.y = 50;
// Set initial color based on saved score
if (initialScore >= 40) {
scoreText.fill = 0xff00ff; // Magenta for 40+
scoreText.tint = 0xff00ff;
} else if (initialScore >= 30) {
scoreText.fill = 0xffd700; // Gold
scoreText.tint = 0xffd700;
} else if (initialScore >= 20) {
scoreText.fill = 0xc0c0c0; // Silver
scoreText.tint = 0xc0c0c0;
} else if (initialScore >= 10) {
scoreText.fill = 0xcd7f32; // Bronze
scoreText.tint = 0xcd7f32;
} else {
scoreText.fill = 0xffffff; // Default white
scoreText.tint = 0xffffff;
}
function createMainMenu() {
createMenuOverlay();
showMenuOverlay();
menuContainer = game.addChild(new Container());
// Title
var titleText = new Text2(getText('title'), {
size: 360,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 800;
// Add black outline effect by creating shadow text
var titleShadow = new Text2(getText('title'), {
size: 360,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 4;
titleShadow.y = 800 + 4;
menuContainer.addChild(titleShadow);
menuContainer.addChild(titleText);
// Play button
var playButton = menuContainer.addChild(new MenuButton(getText('play'), function () {
startGame();
}));
playButton.x = 2048 / 2;
playButton.y = 1200;
// Skins button
var skinsButton = menuContainer.addChild(new MenuButton(getText('skins'), function () {
showSkinMenu();
}));
skinsButton.x = 2048 / 2;
skinsButton.y = 1500;
// Map button
var mapButton = menuContainer.addChild(LK.getAsset('mapButton', {
anchorX: 0.5,
anchorY: 0.5
}));
mapButton.x = 2048 / 2 - 200;
mapButton.y = 1800;
mapButton.down = function () {
LK.getSound('Map').play();
showMapMenu();
};
// High Scores and Achievements button
var highscoreButton = menuContainer.addChild(LK.getAsset('HighscoreButton', {
anchorX: 0.5,
anchorY: 0.5
}));
highscoreButton.x = 2048 / 2 + 200;
highscoreButton.y = 1800;
highscoreButton.down = function () {
LK.getSound('Trophy').play();
showHighscoreWindow();
};
// Gear icon for language selection
var gearIcon = menuContainer.addChild(LK.getAsset('gearIcon', {
anchorX: 0.5,
anchorY: 0.5
}));
gearIcon.x = 2048 - 150;
gearIcon.y = 150;
gearIcon.down = function () {
LK.getSound('Gear').play();
showSettingsMenu();
};
// Show current map display
var currentMapContainer = menuContainer.addChild(new Container());
currentMapContainer.x = 2048 / 2;
currentMapContainer.y = 2300;
// Get current map info
var currentMapName = 'Strand';
if (currentBackground === 'background_jungle') {
currentMapName = 'Dschungel';
} else if (currentBackground === 'background_volcano') {
currentMapName = 'Vulkan';
} else if (currentBackground === 'background_space') {
currentMapName = 'Space';
} else if (currentBackground === 'background_swamp') {
currentMapName = 'Swamp';
}
// Current map preview
var currentMapPreview = currentMapContainer.addChild(LK.getAsset(currentBackground, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.2,
scaleY: 0.16
}));
// Current map name
var currentMapNameText = new Text2(currentMapName, {
size: 60,
fill: 0xFFFFFF
});
currentMapNameText.anchor.set(0.5, 0.5);
currentMapNameText.x = 0;
currentMapNameText.y = 120;
currentMapContainer.addChild(currentMapNameText);
// Highlight current map
currentMapPreview.tint = 0x90ee90;
// High score display
var highScore = storage.highScore || 0;
var highScoreText = new Text2(getText('highScore') + highScore, {
size: 180,
fill: 0xFFFFFF
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 2048 / 2;
highScoreText.y = 2500;
menuContainer.addChild(highScoreText);
// Turtle decoration removed
}
function showSkinMenu() {
if (menuContainer) {
menuContainer.visible = false;
}
skinMenuContainer = game.addChild(new Container());
// Title
var titleText = new Text2(getText('chooseSkin'), {
size: 240,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 600;
// Add title shadow for better contrast
var titleShadow = new Text2(getText('chooseSkin'), {
size: 240,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 3;
titleShadow.y = 600 + 3;
skinMenuContainer.addChild(titleShadow);
skinMenuContainer.addChild(titleText);
// Skin options
var skins = ['turtle_default', 'turtle_red'];
// Add golden turtle if unlocked
if (storage.goldenTurtleUnlocked) {
skins.push('turtle_golden');
}
var startX = 2048 / 2 - 600;
var startY = 900;
for (var i = 0; i < skins.length; i++) {
var skinButton = skinMenuContainer.addChild(new SkinButton(skins[i], function (skin) {
return function () {
currentSkin = skin;
storage.selectedSkin = skin;
hideSkinMenu();
};
}(skins[i])));
skinButton.x = startX + i * 600;
skinButton.y = startY;
// Highlight selected skin
if (skins[i] === currentSkin) {
skinButton.graphics.tint = 0x90ee90;
}
}
// Back button
var backButton = skinMenuContainer.addChild(new MenuButton(getText('back'), function () {
hideSkinMenu();
}));
backButton.x = 2048 / 2;
backButton.y = 1400;
}
function hideSkinMenu() {
if (skinMenuContainer) {
skinMenuContainer.destroy();
skinMenuContainer = null;
}
if (menuContainer) {
menuContainer.visible = true;
}
showMenuOverlay();
}
function showSettingsMenu() {
if (menuContainer) {
menuContainer.visible = false;
}
settingsMenuContainer = game.addChild(new Container());
// Title
var titleText = new Text2('Settings', {
size: 240,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 600;
// Add title shadow for better contrast
var titleShadow = new Text2('Settings', {
size: 240,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 3;
titleShadow.y = 600 + 3;
settingsMenuContainer.addChild(titleShadow);
settingsMenuContainer.addChild(titleText);
// Music toggle button
var musicToggle = settingsMenuContainer.addChild(new MusicButton(musicEnabled, function (enabled) {
musicEnabled = enabled;
storage.musicEnabled = enabled;
if (!musicEnabled) {
LK.stopMusic();
currentMusicTrack = null;
} else {
playBackgroundMusic();
}
}));
musicToggle.x = 2048 / 2;
musicToggle.y = 1100;
// Language button
var languageButton = settingsMenuContainer.addChild(new MenuButton(getText('selectLanguage'), function () {
hideSettingsMenu();
showLanguageMenu();
}));
languageButton.x = 2048 / 2;
languageButton.y = 1400;
// Reset button
var resetButton = settingsMenuContainer.addChild(new MenuButton('RESET', function () {
showResetConfirmation();
}));
resetButton.x = 2048 / 2;
resetButton.y = 1700;
// Make reset button red
resetButton.children[0].tint = 0xff0000; // Tint the button graphics red
// Back button
var backButton = settingsMenuContainer.addChild(new MenuButton(getText('back'), function () {
hideSettingsMenu();
}));
backButton.x = 2048 / 2;
backButton.y = 2000;
}
function hideSettingsMenu() {
if (settingsMenuContainer) {
settingsMenuContainer.destroy();
settingsMenuContainer = null;
}
if (menuContainer) {
menuContainer.visible = true;
}
showMenuOverlay();
}
var resetConfirmationContainer = null;
function showResetConfirmation() {
if (settingsMenuContainer) {
settingsMenuContainer.visible = false;
}
LK.getSound('Alarm').play();
resetConfirmationContainer = game.addChild(new Container());
// Title
var titleText = new Text2('Are you sure you want to reset?', {
size: 180,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 1000;
// Add title shadow for better contrast
var titleShadow = new Text2('Are you sure you want to reset?', {
size: 180,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 3;
titleShadow.y = 1000 + 3;
resetConfirmationContainer.addChild(titleShadow);
resetConfirmationContainer.addChild(titleText);
// Flash screen red repeatedly
var flashInterval = LK.setInterval(function () {
LK.effects.flashScreen(0xff0000, 200); // Flash red for 200ms
}, 500); // Repeat every 500ms
resetConfirmationContainer.flashInterval = flashInterval; // Store interval ID to clear later
// Yes button
var yesButton = resetConfirmationContainer.addChild(new MenuButton('Confirm Reset', function () {
LK.getSound('Warning').play();
performReset();
hideResetConfirmation();
}));
// Tint the button graphics red
yesButton.children[0].tint = 0xff0000;
yesButton.x = 2048 / 2 - 300;
yesButton.y = 1400;
// No button
var noButton = resetConfirmationContainer.addChild(new MenuButton('NO', function () {
hideResetConfirmation();
}));
noButton.x = 2048 / 2 + 300;
noButton.y = 1400;
}
function hideResetConfirmation() {
if (resetConfirmationContainer) {
if (resetConfirmationContainer.flashInterval) {
LK.clearInterval(resetConfirmationContainer.flashInterval);
}
resetConfirmationContainer.destroy();
resetConfirmationContainer = null;
}
if (settingsMenuContainer) {
settingsMenuContainer.visible = true;
}
}
function performReset() {
// Reset all stored data
storage.highScore = 0;
storage.currentScore = 0;
storage.selectedSkin = 'turtle_default';
storage.selectedBackground = 'background_beach';
storage.selectedLanguage = 'English';
storage.goldenTurtleUnlocked = false;
storage.musicEnabled = false;
storage.ambienceEnabled = true;
// Disable all interactions during reset animation
gamePaused = true;
// Disable all menu interactions by hiding all menu containers
if (resetConfirmationContainer) {
resetConfirmationContainer.visible = false;
}
if (settingsMenuContainer) {
settingsMenuContainer.visible = false;
}
if (menuContainer) {
menuContainer.visible = false;
}
if (skinMenuContainer) {
skinMenuContainer.visible = false;
}
if (mapMenuContainer) {
mapMenuContainer.visible = false;
}
if (highscoreWindowContainer) {
highscoreWindowContainer.visible = false;
}
if (languageMenuContainer) {
languageMenuContainer.visible = false;
}
// Start reset animation
// First, everything turns red slowly
tween(game, {
tint: 0xff0000
}, {
duration: 1000,
easing: tween.linear,
onFinish: function onFinish() {
// Then everything turns dark slowly
createDarkOverlay();
// Ensure darkOverlay exists before tweening
if (darkOverlay) {
tween(darkOverlay, {
alpha: 1.0
}, {
duration: 1000,
easing: tween.linear,
onFinish: function onFinish() {
// Then everything explodes
// Create an explosion effect (simple particle burst)
for (var i = 0; i < 50; i++) {
var particle = game.addChild(LK.getAsset('sandParticle', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
tint: 0xff0000 + Math.random() * 0x00ffff // Random red to yellow tint
}));
var speed = Math.random() * 30 + 10;
var angle = Math.random() * Math.PI * 2;
var velocityX = Math.cos(angle) * speed;
var velocityY = Math.sin(angle) * speed;
var gravity = 1.5;
var lifespan = Math.random() * 60 + 30; // particles last 0.5 to 1 second
particle.update = function () {
this.x += velocityX;
this.y += velocityY;
velocityY += gravity;
this.alpha -= 1 / lifespan;
if (this.alpha <= 0) {
this.destroy();
}
};
}
// Display reset success message
var resetMessage = new Text2(currentLanguage === 'Deutsch' ? 'Speicherdaten erfolgreich gelöscht' : 'Your data has been successfully reset.', {
size: 100,
fill: 0xFFFFFF
});
resetMessage.anchor.set(0.5, 0.5);
resetMessage.x = 2048 / 2;
resetMessage.y = 2732 / 2;
resetMessage.fill = 0xff0000; // Make the text red
game.addChild(resetMessage);
// Play the Memories sound effect when the message appears
LK.getSound('Memories').play();
// Fade out the message after a short delay
tween(resetMessage, {
alpha: 0
}, {
duration: 1500,
delay: 1000,
onFinish: function onFinish() {
resetMessage.destroy();
// After the message fades out, fade the dark overlay to white
if (darkOverlay) {
tween(darkOverlay, {
tint: 0xffffff // Change tint to white
}, {
duration: 1000,
// Duration for fading to white
easing: tween.linear
});
}
}
});
// Reset current game variables after animation
currentSkin = 'turtle_default';
currentBackground = 'background_beach';
currentLanguage = 'English';
musicEnabled = false;
ambienceEnabled = true;
// Reset score display
scoreText.setText('0');
scoreText.fill = 0xffffff;
scoreText.tint = 0xffffff;
// Stop any music
LK.stopMusic();
currentMusicTrack = null;
// Change background to default
changeBackground('background_beach');
// Return to main menu
hideSettingsMenu();
// Reset game tint
game.tint = 0xffffff;
// Re-enable interactions after reset animation
gamePaused = false;
// Re-show main menu
if (menuContainer) {
menuContainer.visible = true;
}
// Clean up dark overlay after explosion
if (darkOverlay) {
// Animate the dark overlay to fade to white
tween(darkOverlay, {
tint: 0xffffff,
alpha: 1.0 // Stay white for a moment
}, {
duration: 1500,
// Duration for fading to white
easing: tween.linear,
onFinish: function onFinish() {
// Stay white for a quarter second, then fade out and clear
LK.setTimeout(function () {
if (darkOverlay) {
tween(darkOverlay, {
alpha: 0.0 // Fade out the alpha as well
}, {
duration: 500,
// Fade out quickly
easing: tween.linear,
onFinish: function onFinish() {
darkOverlay.destroy();
darkOverlay = null;
}
});
}
}, 250); // Stay white for 250ms
}
});
}
}
});
} // Close darkOverlay existence check
}
});
if (menuContainer) {
menuContainer.destroy();
menuContainer = null;
}
createMainMenu();
}
function showLanguageMenu() {
if (menuContainer) {
menuContainer.visible = false;
}
languageMenuContainer = game.addChild(new Container());
// Title
var titleText = new Text2(getText('selectLanguage'), {
size: 240,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 800;
// Add title shadow for better contrast
var titleShadow = new Text2(getText('selectLanguage'), {
size: 240,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 3;
titleShadow.y = 800 + 3;
languageMenuContainer.addChild(titleShadow);
languageMenuContainer.addChild(titleText);
// Language options
var languages = ['English', 'Deutsch'];
var startY = 1200;
for (var i = 0; i < languages.length; i++) {
var langButton = languageMenuContainer.addChild(new LanguageButton(languages[i], function (lang) {
return function () {
currentLanguage = lang;
storage.selectedLanguage = lang;
hideLanguageMenu();
// Refresh main menu with new language
if (menuContainer) {
menuContainer.destroy();
menuContainer = null;
}
createMainMenu();
};
}(languages[i])));
langButton.x = 2048 / 2;
langButton.y = startY + i * 300;
// Highlight selected language
if (languages[i] === currentLanguage) {
langButton.graphics.tint = 0x90ee90;
}
}
// Back button
var backButton = languageMenuContainer.addChild(new MenuButton(getText('back'), function () {
hideLanguageMenu();
}));
backButton.x = 2048 / 2;
backButton.y = 2500;
}
function hideLanguageMenu() {
if (languageMenuContainer) {
languageMenuContainer.destroy();
languageMenuContainer = null;
}
showSettingsMenu();
}
function showHighscoreWindow() {
if (menuContainer) {
menuContainer.visible = false;
}
highscoreWindowContainer = game.addChild(new Container());
// Create scrollable content container
var scrollContainer = highscoreWindowContainer.addChild(new Container());
var scrollY = 0;
var maxScrollY = 0;
var contentHeight = 0;
// Title
var titleText = new Text2('High Scores and Achievements', {
size: 180,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 400;
// Add title shadow for better contrast
var titleShadow = new Text2('High Scores and Achievements', {
size: 180,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 3;
titleShadow.y = 400 + 3;
highscoreWindowContainer.addChild(titleShadow);
highscoreWindowContainer.addChild(titleText);
var currentY = 600;
// High Score Section
var highScoreLabel = new Text2('High Score', {
size: 150,
fill: 0xFFD700
});
highScoreLabel.anchor.set(0.5, 0.5);
highScoreLabel.x = 2048 / 2;
highScoreLabel.y = currentY;
scrollContainer.addChild(highScoreLabel);
currentY += 200;
// Get highscore
var highScore = storage.highScore || 0;
if (highScore === 0) {
// No high score yet - show message
var noScoreText = new Text2('No high score yet!', {
size: 120,
fill: 0xFFFFFF
});
noScoreText.anchor.set(0.5, 0.5);
noScoreText.x = 2048 / 2;
noScoreText.y = currentY;
scrollContainer.addChild(noScoreText);
currentY += 150;
} else {
// Show high score with trophy styling
var highScoreText = new Text2(highScore.toString(), {
size: 200,
fill: 0xFFD700
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 2048 / 2;
highScoreText.y = currentY;
scrollContainer.addChild(highScoreText);
currentY += 200;
// Add trophy icon or decoration
var trophyText = new Text2('🏆', {
size: 120,
fill: 0xFFD700
});
trophyText.anchor.set(0.5, 0.5);
trophyText.x = 2048 / 2;
trophyText.y = currentY;
scrollContainer.addChild(trophyText);
currentY += 150;
}
// Achievements Section
currentY += 100;
var achievementsLabel = new Text2('Achievements', {
size: 150,
fill: 0x90ee90
});
achievementsLabel.anchor.set(0.5, 0.5);
achievementsLabel.x = 2048 / 2;
achievementsLabel.y = currentY;
scrollContainer.addChild(achievementsLabel);
currentY += 200;
// Check and display achievements
var achievements = [];
// Bronze Rank Achievement
if (storage.highScore >= 10) {
achievements.push({
name: 'Bronze Rank',
desc: 'Reach score of 10'
});
}
// Silver Rank Achievement
if (storage.highScore >= 20) {
achievements.push({
name: 'Silver Rank',
desc: 'Reach score of 20'
});
}
// Gold Rank Achievement
if (storage.highScore >= 30) {
achievements.push({
name: 'Gold Rank',
desc: 'Reach score of 30'
});
}
// Master Rank Achievement
if (storage.highScore >= 40) {
achievements.push({
name: 'Master Rank',
desc: 'Reach score of 40'
});
}
// Explorer Achievement
if (storage.explorerAchieved) {
achievements.push({
name: 'Explorer',
desc: 'Jump on every map'
});
}
// Display achievements or no achievements message
if (achievements.length === 0) {
var noAchievementsText = new Text2('No achievements yet!', {
size: 120,
fill: 0xFFFFFF
});
noAchievementsText.anchor.set(0.5, 0.5);
noAchievementsText.x = 2048 / 2;
noAchievementsText.y = currentY;
scrollContainer.addChild(noAchievementsText);
currentY += 150;
} else {
for (var i = 0; i < achievements.length; i++) {
// Achievement name
var achievementName = new Text2(achievements[i].name, {
size: 100,
fill: 0xFFD700
});
achievementName.anchor.set(0.5, 0.5);
achievementName.x = 2048 / 2;
achievementName.y = currentY;
scrollContainer.addChild(achievementName);
currentY += 120;
// Achievement description
var achievementDesc = new Text2(achievements[i].desc, {
size: 80,
fill: 0xCCCCCC
});
achievementDesc.anchor.set(0.5, 0.5);
achievementDesc.x = 2048 / 2;
achievementDesc.y = currentY;
scrollContainer.addChild(achievementDesc);
currentY += 150;
}
}
// Calculate content height and max scroll
contentHeight = currentY;
maxScrollY = Math.max(0, contentHeight - 1800); // Visible area height
// Scroll handling
var isScrolling = false;
var lastTouchY = 0;
highscoreWindowContainer.down = function (x, y) {
if (gamePaused) return;
isScrolling = true;
lastTouchY = y;
};
highscoreWindowContainer.move = function (x, y) {
if (gamePaused) return;
if (isScrolling) {
var deltaY = y - lastTouchY;
scrollY += deltaY;
scrollY = Math.max(-maxScrollY, Math.min(0, scrollY));
scrollContainer.y = scrollY;
lastTouchY = y;
}
};
highscoreWindowContainer.up = function () {
if (gamePaused) return;
isScrolling = false;
};
// Back button
var backButton = highscoreWindowContainer.addChild(new MenuButton(getText('back'), function () {
if (gamePaused) return;
hideHighscoreWindow();
}));
backButton.x = 2048 / 2;
backButton.y = 2500;
}
function hideHighscoreWindow() {
if (highscoreWindowContainer) {
highscoreWindowContainer.destroy();
highscoreWindowContainer = null;
}
if (menuContainer) {
menuContainer.visible = true;
}
showMenuOverlay();
}
function showMapMenu() {
if (menuContainer) {
menuContainer.visible = false;
}
mapMenuContainer = game.addChild(new Container());
// Title
var titleText = new Text2('Select Map', {
size: 240,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 400;
// Add title shadow for better contrast
var titleShadow = new Text2('Select Map', {
size: 240,
fill: 0x000000
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 2048 / 2 + 3;
titleShadow.y = 400 + 3;
mapMenuContainer.addChild(titleShadow);
mapMenuContainer.addChild(titleText);
// Map options with background previews
var mapTypes = [{
id: 'background_beach',
name: 'Strand'
}, {
id: 'background_jungle',
name: 'Dschungel'
}, {
id: 'background_volcano',
name: 'Vulkan'
}, {
id: 'background_space',
name: 'Space'
}, {
id: 'background_swamp',
name: 'Swamp'
}];
var startX = 2048 / 2 - 600;
var startY = 1000;
var spacing = 300;
for (var i = 0; i < mapTypes.length; i++) {
var mapContainer = mapMenuContainer.addChild(new Container());
mapContainer.x = startX + i * spacing;
mapContainer.y = startY;
// Background preview
var bgPreview = mapContainer.addChild(LK.getAsset(mapTypes[i].id, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.32,
scaleY: 0.24
}));
// Map name
var mapNameText = new Text2(mapTypes[i].name, {
size: 120,
fill: 0xFFFFFF
});
mapNameText.anchor.set(0.5, 0.5);
mapNameText.x = 0;
mapNameText.y = 200;
// Add text shadow for better contrast
var mapNameShadow = new Text2(mapTypes[i].name, {
size: 120,
fill: 0x000000
});
mapNameShadow.anchor.set(0.5, 0.5);
mapNameShadow.x = 2;
mapNameShadow.y = 202;
mapContainer.addChild(mapNameShadow);
mapContainer.addChild(mapNameText);
// Highlight selected map
if (mapTypes[i].id === currentBackground) {
bgPreview.tint = 0x90ee90;
}
// Make clickable
mapContainer.down = function (mapType) {
return function () {
LK.getSound('Lever').play();
changeBackground(mapType.id);
hideMapMenu();
};
}(mapTypes[i]);
}
// Back button
var backButton = mapMenuContainer.addChild(new MenuButton(getText('back'), function () {
hideMapMenu();
}));
backButton.x = 2048 / 2;
backButton.y = 2400;
}
function hideMapMenu() {
if (mapMenuContainer) {
mapMenuContainer.destroy();
mapMenuContainer = null;
}
if (menuContainer) {
menuContainer.visible = true;
}
showMenuOverlay();
}
function playBackgroundMusic() {
var musicTrack = null;
if (gameState === 'menu') {
if (musicEnabled) {
musicTrack = 'Menus';
}
} else if (gameState === 'playing') {
// During gameplay, play music if music is enabled, otherwise play ambience if ambience is enabled
if (musicEnabled) {
if (currentBackground === 'background_beach') {
musicTrack = 'Beach';
} else if (currentBackground === 'background_jungle') {
musicTrack = 'Jungle';
} else if (currentBackground === 'background_volcano') {
musicTrack = 'Volcano';
} else if (currentBackground === 'background_space') {
musicTrack = 'Space';
} else if (currentBackground === 'background_swamp') {
musicTrack = 'Ambience Swamp';
}
} else if (ambienceEnabled) {
// Play ambience tracks for gameplay even when music is disabled
if (currentBackground === 'background_beach') {
musicTrack = 'Beach';
} else if (currentBackground === 'background_jungle') {
musicTrack = 'Jungle';
} else if (currentBackground === 'background_volcano') {
musicTrack = 'Volcano';
} else if (currentBackground === 'background_space') {
musicTrack = 'Space';
} else if (currentBackground === 'background_swamp') {
musicTrack = 'Ambience Swamp';
}
}
}
if (musicTrack && musicTrack !== currentMusicTrack) {
LK.playMusic(musicTrack);
currentMusicTrack = musicTrack;
}
}
function changeBackground(newBackground) {
// Clean up existing background elements
for (var i = 0; i < backgroundElements.length; i++) {
backgroundElements[i].destroy();
}
backgroundElements = [];
currentBackground = newBackground;
storage.selectedBackground = newBackground;
// Recreate scrolling background with new background
for (var i = 0; i < 2; i++) {
var bg = game.addChild(LK.getAsset(currentBackground, {
anchorX: 0,
anchorY: 0,
x: i * 2048,
y: 0
}));
backgroundElements.push(bg);
// Move background to back
game.setChildIndex(bg, 0);
}
// Update ground asset
if (ground) {
ground.destroy();
ground = game.addChild(createGround());
}
// Play appropriate background music only during gameplay
if (gameState === 'playing') {
playBackgroundMusic();
}
}
function startGame() {
gameState = 'playing';
gameScore = 0;
lastBoulderTime = 0;
boulderInterval = 200; // much more frequent spawning
// Use selected background for gameplay
changeBackground(currentBackground);
// Recreate ground with correct asset
if (ground) {
ground.destroy();
ground = game.addChild(createGround());
}
// Hide menu and overlay
if (menuContainer) {
menuContainer.visible = false;
}
hideMenuOverlay();
// Create turtle
turtle = game.addChild(new Turtle());
turtle.setSkin(currentSkin);
turtle.x = 300;
// Lower turtle into ground in jungle map to simulate being stuck in mud
if (currentBackground === 'background_jungle') {
turtle.y = ground.y + 30; // Lower turtle by 30 pixels into the ground
turtle.groundY = ground.y + 30;
} else {
turtle.y = ground.y;
turtle.groundY = ground.y;
}
// Clean up obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].destroy();
}
obstacles = [];
// Clean up palm trees array for backwards compatibility
for (var i = palmTrees.length - 1; i >= 0; i--) {
palmTrees[i].destroy();
}
palmTrees = [];
// Clean up turtle backs
for (var i = turtleBacks.length - 1; i >= 0; i--) {
turtleBacks[i].destroy();
}
turtleBacks = [];
// Clear existing turtle backs
for (var i = turtleBacks.length - 1; i >= 0; i--) {
turtleBacks[i].destroy();
}
turtleBacks = [];
// Save current score and update display with color changes
storage.currentScore = gameScore;
scoreText.setText(gameScore);
// Change score text color based on thresholds
if (gameScore >= 40) {
// Special color for 40+ (rainbow effect using tween)
scoreText.fill = 0xff00ff; // Magenta
tween(scoreText, {
tint: 0x00ffff
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(scoreText, {
tint: 0xffff00
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(scoreText, {
tint: 0xff00ff
}, {
duration: 500,
easing: tween.easeInOut
});
}
});
}
});
} else if (gameScore >= 30) {
// Gold
scoreText.fill = 0xffd700;
scoreText.tint = 0xffd700;
} else if (gameScore >= 20) {
// Silver
scoreText.fill = 0xc0c0c0;
scoreText.tint = 0xc0c0c0;
} else if (gameScore >= 10) {
// Bronze
scoreText.fill = 0xcd7f32;
scoreText.tint = 0xcd7f32;
} else {
// Default white
scoreText.fill = 0xffffff;
scoreText.tint = 0xffffff;
}
// Start background music
playBackgroundMusic();
}
function gameOver() {
actualGameOver();
}
function actualGameOver() {
gameState = 'gameOver';
gamePaused = true; // Stop all movement immediately
// Update high score
if (gameScore > (storage.highScore || 0)) {
storage.highScore = gameScore;
}
// Note: Specific hit sounds are now played on collision detection
// Flash screen turquoise for laser wall hits, red for others
var flashColor = 0xff0000; // Default red
// Check if the last collision was with a laser wall by checking if there are any laser walls in obstacles
for (var i = 0; i < obstacles.length; i++) {
if (obstacles[i] instanceof LaserWall && turtle && turtle.intersects(obstacles[i])) {
flashColor = 0x40e0d0; // Turquoise for laser wall collision
break;
}
}
LK.effects.flashScreen(flashColor, 500);
// Create dark overlay and animate it
createDarkOverlay();
tween(darkOverlay, {
alpha: 1.0
}, {
duration: 1000,
easing: tween.easeInOut
});
// Show game over after delay - wait for hit sound to complete
LK.setTimeout(function () {
LK.showGameOver('Score: ' + gameScore);
// Reset everything after game over is shown
resetGame();
}, 1500);
}
function resetGame() {
gameState = 'menu';
gamePaused = false; // Reset pause state
// Keep dark overlay - don't clean it up until retry is pressed
// if (darkOverlay) {
// darkOverlay.destroy();
// darkOverlay = null;
// }
// Stop background music when leaving gameplay
LK.stopMusic();
currentMusicTrack = null;
// Reset game variables
gameScore = 0;
lastBoulderTime = 0;
boulderInterval = 200;
difficultyLevel = 1;
speedMultiplier = 1.0;
// Clean up turtle
if (turtle) {
turtle.destroy();
turtle = null;
}
// Clean up obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].destroy();
}
obstacles = [];
// Clean up palm trees array for backwards compatibility
for (var i = palmTrees.length - 1; i >= 0; i--) {
palmTrees[i].destroy();
}
palmTrees = [];
// Reset score display and color
scoreText.setText('0');
scoreText.fill = 0xffffff; // Reset to white
scoreText.tint = 0xffffff;
// Stop any ongoing color tweens
tween.stop(scoreText, {
tint: true
});
// Show menu
if (menuContainer) {
menuContainer.visible = true;
showMenuOverlay();
} else {
createMainMenu();
}
// Play menu music when returning to menu
playBackgroundMusic();
}
function showAchievementNotification(achievementName) {
// Create achievement container if it doesn't exist
if (achievementContainer) {
achievementContainer.destroy();
}
achievementContainer = game.addChild(new Container());
// Create white text box background
var textBox = achievementContainer.addChild(LK.getAsset('background_sky', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 2,
tint: 0xffffff,
alpha: 0.9
}));
// Create trophy icon
var trophyIcon = achievementContainer.addChild(LK.getAsset('HighscoreButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4,
x: -200,
y: 0
}));
// Create achievement text
var achievementText = new Text2(achievementName, {
size: 120,
fill: 0x000000
});
achievementText.anchor.set(0.5, 0.5);
achievementText.x = 50; // Move text slightly right to make room for trophy
achievementContainer.addChild(achievementText);
// Position at bottom of screen initially
achievementContainer.x = 2048 / 2;
achievementContainer.y = 2732 + 100; // Start below screen
// Animation sequence: fly up to bottom, stay briefly, then fly down
tween(achievementContainer, {
y: 2732 - 200 // Fly to bottom area of screen
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
// Stay at bottom for a moment
tween(achievementContainer, {
y: 2732 - 200 // Stay in place
}, {
duration: 1500,
onFinish: function onFinish() {
// Fly back down off screen
tween(achievementContainer, {
y: 2732 + 100
}, {
duration: 800,
easing: tween.easeIn,
onFinish: function onFinish() {
if (achievementContainer) {
achievementContainer.destroy();
achievementContainer = null;
}
}
});
}
});
}
});
}
function createDustParticles(x, y) {
for (var i = 0; i < 8; i++) {
var particle = game.addChild(LK.getAsset('sandParticle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5 + Math.random() * 0.8,
scaleY: 0.5 + Math.random() * 0.8,
x: x + (Math.random() - 0.5) * 120,
y: y - 10,
alpha: 0.8
}));
// Create flying sand effect with arc trajectory
var targetY = y - Math.random() * 150 - 80;
var targetX = particle.x + (Math.random() - 0.5) * 200;
var midY = y - Math.random() * 80 - 40;
// First phase: launch upward with arc
tween(particle, {
y: midY,
x: targetX * 0.6,
alpha: 0.9
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
// Second phase: fall down with gravity
tween(particle, {
y: targetY,
x: targetX,
alpha: 0
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
particle.destroy();
}
});
}
});
}
}
// Touch input for jumping
game.down = function (x, y, obj) {
if (gameState === 'playing' && turtle && !gamePaused) {
turtle.jump();
}
};
// Handle retry button press to clear dark overlay
LK.on('retry', function () {
// Clear dark overlay when retry is pressed
if (darkOverlay) {
darkOverlay.destroy();
darkOverlay = null;
}
});
// Main game loop
game.update = function () {
// Don't update anything if game is paused
if (gamePaused) return;
// Update scrolling background only when playing
if (gameState === 'playing') {
for (var i = 0; i < backgroundElements.length; i++) {
var bg = backgroundElements[i];
bg.x += backgroundScrollSpeed;
// Reset position when background moves off screen
if (bg.x <= -2048) {
// Find the other background element and position relative to it
var otherBg = backgroundElements[1 - i];
bg.x = otherBg.x + 2048;
}
}
}
if (gameState === 'playing') {
// Spawn obstacles based on current map
if (LK.ticks - lastBoulderTime > boulderInterval) {
var obstacle = null;
if (currentBackground === 'background_beach') {
obstacle = game.addChild(new PalmTree());
} else if (currentBackground === 'background_jungle') {
obstacle = game.addChild(new JungleTreeTrunk());
} else if (currentBackground === 'background_volcano') {
obstacle = game.addChild(new LavaGeyser());
} else if (currentBackground === 'background_space') {
// Randomly spawn laser walls for space map
var laserWallTypes = ['laser_wall', 'laser_wall_2', 'laser_wall_3', 'laser_wall_4'];
var randomLaserType = laserWallTypes[Math.floor(Math.random() * laserWallTypes.length)];
obstacle = game.addChild(new LaserWall(randomLaserType));
} else if (currentBackground === 'background_swamp') {
obstacle = game.addChild(new LilyPad());
}
if (obstacle) {
obstacle.x = 2048 + 300; // Spawn further off-screen to hide spawning
obstacle.y = ground.y;
obstacle.speed = obstacle.speed * speedMultiplier; // Apply speed multiplier
obstacles.push(obstacle);
}
lastBoulderTime = LK.ticks;
// Progressive difficulty system with speed cap at score 20
var newDifficultyLevel = Math.floor(gameScore / 5) + 1;
if (newDifficultyLevel > difficultyLevel) {
difficultyLevel = newDifficultyLevel;
// Cap speed multiplier at 1.0 after score 20 (no speed increase)
if (gameScore >= 20) {
speedMultiplier = 1.0; // No speed increase after score 20
} else {
speedMultiplier = Math.min(1.0, 1.0 + (difficultyLevel - 1) * 0.2); // 20% speed increase per level until score 20
}
// Play celebrate sound when difficulty increases
LK.getSound('celebrate').play();
}
// Increase spawn rate more moderately
if (boulderInterval > minBoulderInterval) {
var reduction = Math.max(5, Math.floor(difficultyLevel * 2)); // More moderate reduction
boulderInterval = Math.max(minBoulderInterval, boulderInterval - reduction);
}
}
// Update obstacles and check collisions
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
// Remove off-screen obstacles (hide despawning)
if (obstacle.x < -300) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check if obstacle was passed for scoring
if (!obstacle.passed && obstacle.x < turtle.x) {
obstacle.passed = true;
gameScore++;
// Save current score and update display with color changes
storage.currentScore = gameScore;
scoreText.setText(gameScore);
// Change score text color based on thresholds
if (gameScore >= 40) {
// Special color for 40+ (rainbow effect using tween)
scoreText.fill = 0xff00ff; // Magenta
tween(scoreText, {
tint: 0x00ffff
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(scoreText, {
tint: 0xffff00
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(scoreText, {
tint: 0xff00ff
}, {
duration: 500,
easing: tween.easeInOut
});
}
});
}
});
// Play special trophy sound for reaching 40 if this is the first time
if (gameScore == 40 && (storage.highScore || 0) < 40) {
LK.getSound('trophy_gold').play();
showAchievementNotification("Master Rank");
}
} else if (gameScore >= 30) {
// Gold
scoreText.fill = 0xffd700;
scoreText.tint = 0xffd700;
// Play gold trophy sound for reaching 30 if this is the first time
if (gameScore == 30 && (storage.highScore || 0) < 30) {
LK.getSound('trophy_gold').play();
// Unlock golden turtle skin permanently
storage.goldenTurtleUnlocked = true;
// Flash screen golden and pause game briefly
LK.effects.flashScreen(0xffd700, 1000);
// Show achievement notification
showAchievementNotification("Gold Rank");
// Pause game for 1 second
var gameWasPaused = false;
LK.setTimeout(function () {
gameWasPaused = true;
}, 1000);
}
} else if (gameScore >= 20) {
// Silver
scoreText.fill = 0xc0c0c0;
scoreText.tint = 0xc0c0c0;
// Play silver trophy sound for reaching 20 if this is the first time
if (gameScore == 20 && (storage.highScore || 0) < 20) {
LK.getSound('trophy_silver').play();
showAchievementNotification("Silver Rank");
}
} else if (gameScore >= 10) {
// Bronze
scoreText.fill = 0xcd7f32;
scoreText.tint = 0xcd7f32;
// Play bronze trophy sound for reaching 10 if this is the first time
if (gameScore == 10 && (storage.highScore || 0) < 10) {
LK.getSound('trophy_bronze').play();
showAchievementNotification("Bronze Rank");
}
} else {
// Default white
scoreText.fill = 0xffffff;
scoreText.tint = 0xffffff;
}
// Play celebration sound for scoring (but not when ranking up)
var isRankingUp = gameScore == 10 && (storage.highScore || 0) < 10 || gameScore == 20 && (storage.highScore || 0) < 20 || gameScore == 30 && (storage.highScore || 0) < 30 || gameScore == 40 && (storage.highScore || 0) < 40;
if (!isRankingUp) {
LK.getSound('Secret').play();
}
}
// Check collision with turtle
if (turtle && turtle.intersects(obstacle)) {
// Play specific hit sound based on obstacle type
if (obstacle instanceof PalmTree) {
LK.getSound('hit_palm_tree').play();
} else if (obstacle instanceof JungleTreeTrunk) {
LK.getSound('hit_palm_tree').play();
} else if (obstacle instanceof LavaGeyser) {
LK.getSound('hit_lava_geyser').play();
// Create pile of ash at turtle's position
var ash = game.addChild(new PileOfAsh());
ash.x = turtle.x;
ash.y = turtle.y;
// Hide the turtle
turtle.visible = false;
} else if (obstacle instanceof LaserWall) {
LK.getSound('hit_laser_wall').play();
// Create pile of ash at turtle's position (like lava geyser)
var ash = game.addChild(new PileOfAsh());
ash.x = turtle.x;
ash.y = turtle.y;
// Hide the turtle immediately
turtle.visible = false;
// Add a slight delay before game over to show the ash transformation
LK.setTimeout(function () {
gameOver();
}, 100);
return;
} else if (obstacle instanceof LilyPad) {
LK.getSound('hit_lily_pad').play();
}
gameOver();
return;
}
}
}
};
// Initialize main menu
createMainMenu();
// Initialize background music
playBackgroundMusic(); ===================================================================
--- original.js
+++ change.js
@@ -1530,9 +1530,9 @@
musicTrack = 'Volcano';
} else if (currentBackground === 'background_space') {
musicTrack = 'Space';
} else if (currentBackground === 'background_swamp') {
- musicTrack = 'Swamp';
+ musicTrack = 'Ambience Swamp';
}
} else if (ambienceEnabled) {
// Play ambience tracks for gameplay even when music is disabled
if (currentBackground === 'background_beach') {
@@ -1543,9 +1543,9 @@
musicTrack = 'Volcano';
} else if (currentBackground === 'background_space') {
musicTrack = 'Space';
} else if (currentBackground === 'background_swamp') {
- musicTrack = 'Swamp';
+ musicTrack = 'Ambience Swamp';
}
}
}
if (musicTrack && musicTrack !== currentMusicTrack) {
The sand ground of some sort of beach. In-Game asset. 2d. High contrast. No shadows
A small world map. In-Game asset. 2d. High contrast. No shadows
I land turtle with googly eyes wearing a suit and looking to the right. In-Game asset. 2d. High contrast. No shadows
Irregular old land turtle wearing a suit with a red tie in a jumping position. In-Game asset. 2d. High contrast. No shadows
A settings button I can without any background it’s a gear. In-Game asset. 2d. High contrast. No shadows
The beach of a tropical island, though the ocean is not to be seen in the background there is just a vibrant jungle. In-Game asset. 2d. High contrast. No shadows
A lush and vibrant jungle. In-Game asset. 2d. High contrast. No shadows
A area filled with lava and a sky two it’s still pretty vibrant but make sure it can loop without looking bad. In-Game asset. 2d. High contrast. No shadows
Junglee grass ground which is a bit overgrown. In-Game asset. 2d. High contrast. No shadows
Volcanic rocks for a ground. In-Game asset. 2d. High contrast. No shadows
I completely dark red square with some orange parts more in the middle representing a lava block. In-Game asset. 2d. High contrast. No shadows
A crazy almost neon green plant that can grow both on in the jungles and on beaches. In-Game asset. 2d. High contrast. No shadows
A golden land turtle with googly eyes looking to the right. In-Game asset. 2d. High contrast. No shadows
A golden turtle with googly eyes in the jumping position. In-Game asset. 2d. High contrast. No shadows
A pile of burn ash. In-Game asset. 2d. High contrast. No shadows
A trophy without any background. In-Game asset. 2d. High contrast. No shadows
A sterile space station background But it’s still futuristic and definitely seems like it’s made out of metal. In-Game asset. 2d. High contrast. No shadows
A metal plate working as the ground for a space station. In-Game asset. 2d. High contrast. No shadows
A swampy background with mangrove trees and overall overgrown but lush aesthetics. In-Game asset. 2d. High contrast. No shadows
A muddy swamp ground. In-Game asset. 2d. High contrast. No shadows
A background, this picture of a flash eating plant Not eating flesh at least not yet. In-Game asset. 2d. High contrast. No shadows
The street ground of a city. In-Game asset. 2d. High contrast. No shadows
A white car. In-Game asset. 2d. High contrast. No shadows
The skyline of a modern city. In-Game asset. 2d. High contrast. No shadows
Evening image of a mountain range easily looping. In-Game asset. 2d. High contrast. No shadows
The tropical ocean with the shore of an island in the far background easily looping itself. In-Game asset. 2d. High contrast. No shadows
A pirate. In-Game asset. 2d. High contrast. No shadows
The wooden floor of a pirate ship. In-Game asset. 2d. High contrast. No shadows
The pillar of an ancient jungle temple. In-Game asset. 2d. High contrast. No shadows
Ancient trap able to dispense arrows to PS it’s target. In-Game asset. 2d. High contrast. No shadows
The ground for an ancient jungle temple. In-Game asset. 2d. High contrast. No shadows
The background for the inside of an ancient jungle temple. In-Game asset. 2d. High contrast. No shadows
Fully soaked and wet grass and the dirt for the ground element oven to the jump and run. In-Game asset. 2d. High contrast. No shadows
Just a tree. In-Game asset. 2d. High contrast. No shadows
An open space of grass with dark rainy clouds up above Easily looper. In-Game asset. 2d. High contrast. No shadows
hit
Sound effect
jump
Sound effect
Map
Sound effect
Lever
Sound effect
Gear
Sound effect
Land
Sound effect
Secret
Sound effect
celebrate
Sound effect
Started
Sound effect
landing_jungle
Sound effect
landing_volcano
Sound effect
hit_lava_geyser
Sound effect
hit_palm_tree
Sound effect
trophy_bronze
Sound effect
trophy_gold
Sound effect
trophy_silver
Sound effect
Beach
Music
Jungle
Music
Volcano
Music
Warning
Sound effect
Alarm
Sound effect
Memories
Sound effect
Trophy
Sound effect
hit_laser_wall
Sound effect
Space
Music
landing_space
Sound effect
landing_swamp
Sound effect
hit_carnivorous_plant
Sound effect
Swamp
Music
City
Music
hit_car
Sound effect
landing_city
Sound effect
landing_silhouette_mountain
Sound effect
hit_dripstone
Sound effect
hit_pirate
Sound effect
pirate_landing
Sound effect
hit_arrow_trap
Sound effect
landing_ancient_temple
Sound effect
landing_thunderplanes
Sound effect
hit_thundertree
Sound effect
Thunderplanes
Music
thunder
Sound effect