User prompt
make everything like three times bigger and make the background black for now
Code edit (1 edits merged)
Please save this source code
User prompt
Turtle Run
Initial prompt
me a typical autorunner game with a main menu though, where you can change skins, and there is also a play button. The game is called Turtle Run, and the player is a turtle and has to jump over spikes by tapping the screen. The score goes up every time he jumps successfully over a spike.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
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: 40,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function () {
if (callback) callback();
};
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
});
var skinPreview = self.attachAsset(skinType, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
self.down = function () {
if (callback) callback();
};
return self;
});
var Spike = Container.expand(function () {
var self = Container.call(this);
self.speed = -8;
self.passed = false;
var spikeGraphics = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1.0
});
self.update = function () {
self.x += self.speed;
};
return self;
});
var Turtle = Container.expand(function () {
var self = Container.call(this);
self.skinType = 'turtle_default';
self.isJumping = false;
self.jumpSpeed = 0;
self.groundY = 0;
self.gravity = 0.8;
self.jumpPower = -18;
self.graphics = null;
self.setSkin = function (skinType) {
if (self.graphics) {
self.removeChild(self.graphics);
}
self.skinType = skinType;
self.graphics = self.attachAsset(skinType, {
anchorX: 0.5,
anchorY: 1.0
});
};
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.jumpSpeed = self.jumpPower;
LK.getSound('jump').play();
}
};
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;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game states
var gameState = 'menu'; // 'menu', 'playing', 'gameOver'
var currentSkin = storage.selectedSkin || 'turtle_default';
// Game elements
var turtle = null;
var spikes = [];
var ground = null;
var scoreText = null;
var gameScore = 0;
var lastSpikeTime = 0;
var spikeInterval = 2000; // milliseconds
var minSpikeInterval = 800;
// Menu elements
var menuContainer = null;
var skinMenuContainer = null;
// Initialize ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1.0,
x: 0,
y: 2732 - 100
}));
// Initialize score display
scoreText = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreText.y = 50;
function createMainMenu() {
menuContainer = game.addChild(new Container());
// Title
var titleText = new Text2('Turtle Run', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 800;
menuContainer.addChild(titleText);
// Play button
var playButton = menuContainer.addChild(new MenuButton('PLAY', function () {
startGame();
}));
playButton.x = 2048 / 2;
playButton.y = 1200;
// Skins button
var skinsButton = menuContainer.addChild(new MenuButton('SKINS', function () {
showSkinMenu();
}));
skinsButton.x = 2048 / 2;
skinsButton.y = 1320;
// High score display
var highScore = storage.highScore || 0;
var highScoreText = new Text2('High Score: ' + highScore, {
size: 60,
fill: 0xFFFFFF
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 2048 / 2;
highScoreText.y = 1500;
menuContainer.addChild(highScoreText);
}
function showSkinMenu() {
if (menuContainer) {
menuContainer.visible = false;
}
skinMenuContainer = game.addChild(new Container());
// Title
var titleText = new Text2('Choose Skin', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 600;
skinMenuContainer.addChild(titleText);
// Skin options
var skins = ['turtle_default', 'turtle_blue', 'turtle_red', 'turtle_purple'];
var startX = 2048 / 2 - 200;
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 % 2 * 400;
skinButton.y = startY + Math.floor(i / 2) * 150;
// Highlight selected skin
if (skins[i] === currentSkin) {
skinButton.graphics.tint = 0x90ee90;
}
}
// Back button
var backButton = skinMenuContainer.addChild(new MenuButton('BACK', function () {
hideSkinMenu();
}));
backButton.x = 2048 / 2;
backButton.y = 1400;
}
function hideSkinMenu() {
if (skinMenuContainer) {
skinMenuContainer.destroy();
skinMenuContainer = null;
}
if (menuContainer) {
menuContainer.visible = true;
}
}
function startGame() {
gameState = 'playing';
gameScore = 0;
lastSpikeTime = 0;
spikeInterval = 2000;
// Hide menu
if (menuContainer) {
menuContainer.visible = false;
}
// Create turtle
turtle = game.addChild(new Turtle());
turtle.setSkin(currentSkin);
turtle.x = 300;
turtle.y = ground.y;
turtle.groundY = ground.y;
// Clear existing spikes
for (var i = spikes.length - 1; i >= 0; i--) {
spikes[i].destroy();
}
spikes = [];
// Update score display
scoreText.setText(gameScore);
}
function gameOver() {
gameState = 'gameOver';
// Update high score
if (gameScore > (storage.highScore || 0)) {
storage.highScore = gameScore;
}
// Play hit sound
LK.getSound('hit').play();
// Flash screen red
LK.effects.flashScreen(0xff0000, 500);
// Show game over after delay
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
}
function resetGame() {
gameState = 'menu';
// Clean up turtle
if (turtle) {
turtle.destroy();
turtle = null;
}
// Clean up spikes
for (var i = spikes.length - 1; i >= 0; i--) {
spikes[i].destroy();
}
spikes = [];
// Show menu
if (menuContainer) {
menuContainer.visible = true;
} else {
createMainMenu();
}
}
// Touch input for jumping
game.down = function (x, y, obj) {
if (gameState === 'playing' && turtle) {
turtle.jump();
}
};
// Main game loop
game.update = function () {
if (gameState === 'playing') {
// Spawn spikes
if (LK.ticks - lastSpikeTime > spikeInterval) {
var spike = game.addChild(new Spike());
spike.x = 2048 + 100;
spike.y = ground.y;
spikes.push(spike);
lastSpikeTime = LK.ticks;
// Increase difficulty
if (spikeInterval > minSpikeInterval) {
spikeInterval -= 20;
}
}
// Update spikes and check collisions
for (var i = spikes.length - 1; i >= 0; i--) {
var spike = spikes[i];
// Remove off-screen spikes
if (spike.x < -100) {
spike.destroy();
spikes.splice(i, 1);
continue;
}
// Check if spike was passed for scoring
if (!spike.passed && spike.x < turtle.x) {
spike.passed = true;
gameScore++;
scoreText.setText(gameScore);
}
// Check collision with turtle
if (turtle && turtle.intersects(spike)) {
gameOver();
return;
}
}
}
};
// Initialize main menu
createMainMenu(); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,322 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+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: 40,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.down = function () {
+ if (callback) callback();
+ };
+ 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
+ });
+ var skinPreview = self.attachAsset(skinType, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.6,
+ scaleY: 0.6
+ });
+ self.down = function () {
+ if (callback) callback();
+ };
+ return self;
+});
+var Spike = Container.expand(function () {
+ var self = Container.call(this);
+ self.speed = -8;
+ self.passed = false;
+ var spikeGraphics = self.attachAsset('spike', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
+var Turtle = Container.expand(function () {
+ var self = Container.call(this);
+ self.skinType = 'turtle_default';
+ self.isJumping = false;
+ self.jumpSpeed = 0;
+ self.groundY = 0;
+ self.gravity = 0.8;
+ self.jumpPower = -18;
+ self.graphics = null;
+ self.setSkin = function (skinType) {
+ if (self.graphics) {
+ self.removeChild(self.graphics);
+ }
+ self.skinType = skinType;
+ self.graphics = self.attachAsset(skinType, {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ };
+ self.jump = function () {
+ if (!self.isJumping) {
+ self.isJumping = true;
+ self.jumpSpeed = self.jumpPower;
+ LK.getSound('jump').play();
+ }
+ };
+ 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;
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+// Game states
+var gameState = 'menu'; // 'menu', 'playing', 'gameOver'
+var currentSkin = storage.selectedSkin || 'turtle_default';
+// Game elements
+var turtle = null;
+var spikes = [];
+var ground = null;
+var scoreText = null;
+var gameScore = 0;
+var lastSpikeTime = 0;
+var spikeInterval = 2000; // milliseconds
+var minSpikeInterval = 800;
+// Menu elements
+var menuContainer = null;
+var skinMenuContainer = null;
+// Initialize ground
+ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1.0,
+ x: 0,
+ y: 2732 - 100
+}));
+// Initialize score display
+scoreText = new Text2('0', {
+ size: 100,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreText);
+scoreText.y = 50;
+function createMainMenu() {
+ menuContainer = game.addChild(new Container());
+ // Title
+ var titleText = new Text2('Turtle Run', {
+ size: 120,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.x = 2048 / 2;
+ titleText.y = 800;
+ menuContainer.addChild(titleText);
+ // Play button
+ var playButton = menuContainer.addChild(new MenuButton('PLAY', function () {
+ startGame();
+ }));
+ playButton.x = 2048 / 2;
+ playButton.y = 1200;
+ // Skins button
+ var skinsButton = menuContainer.addChild(new MenuButton('SKINS', function () {
+ showSkinMenu();
+ }));
+ skinsButton.x = 2048 / 2;
+ skinsButton.y = 1320;
+ // High score display
+ var highScore = storage.highScore || 0;
+ var highScoreText = new Text2('High Score: ' + highScore, {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ highScoreText.anchor.set(0.5, 0.5);
+ highScoreText.x = 2048 / 2;
+ highScoreText.y = 1500;
+ menuContainer.addChild(highScoreText);
+}
+function showSkinMenu() {
+ if (menuContainer) {
+ menuContainer.visible = false;
+ }
+ skinMenuContainer = game.addChild(new Container());
+ // Title
+ var titleText = new Text2('Choose Skin', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.x = 2048 / 2;
+ titleText.y = 600;
+ skinMenuContainer.addChild(titleText);
+ // Skin options
+ var skins = ['turtle_default', 'turtle_blue', 'turtle_red', 'turtle_purple'];
+ var startX = 2048 / 2 - 200;
+ 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 % 2 * 400;
+ skinButton.y = startY + Math.floor(i / 2) * 150;
+ // Highlight selected skin
+ if (skins[i] === currentSkin) {
+ skinButton.graphics.tint = 0x90ee90;
+ }
+ }
+ // Back button
+ var backButton = skinMenuContainer.addChild(new MenuButton('BACK', function () {
+ hideSkinMenu();
+ }));
+ backButton.x = 2048 / 2;
+ backButton.y = 1400;
+}
+function hideSkinMenu() {
+ if (skinMenuContainer) {
+ skinMenuContainer.destroy();
+ skinMenuContainer = null;
+ }
+ if (menuContainer) {
+ menuContainer.visible = true;
+ }
+}
+function startGame() {
+ gameState = 'playing';
+ gameScore = 0;
+ lastSpikeTime = 0;
+ spikeInterval = 2000;
+ // Hide menu
+ if (menuContainer) {
+ menuContainer.visible = false;
+ }
+ // Create turtle
+ turtle = game.addChild(new Turtle());
+ turtle.setSkin(currentSkin);
+ turtle.x = 300;
+ turtle.y = ground.y;
+ turtle.groundY = ground.y;
+ // Clear existing spikes
+ for (var i = spikes.length - 1; i >= 0; i--) {
+ spikes[i].destroy();
+ }
+ spikes = [];
+ // Update score display
+ scoreText.setText(gameScore);
+}
+function gameOver() {
+ gameState = 'gameOver';
+ // Update high score
+ if (gameScore > (storage.highScore || 0)) {
+ storage.highScore = gameScore;
+ }
+ // Play hit sound
+ LK.getSound('hit').play();
+ // Flash screen red
+ LK.effects.flashScreen(0xff0000, 500);
+ // Show game over after delay
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 500);
+}
+function resetGame() {
+ gameState = 'menu';
+ // Clean up turtle
+ if (turtle) {
+ turtle.destroy();
+ turtle = null;
+ }
+ // Clean up spikes
+ for (var i = spikes.length - 1; i >= 0; i--) {
+ spikes[i].destroy();
+ }
+ spikes = [];
+ // Show menu
+ if (menuContainer) {
+ menuContainer.visible = true;
+ } else {
+ createMainMenu();
+ }
+}
+// Touch input for jumping
+game.down = function (x, y, obj) {
+ if (gameState === 'playing' && turtle) {
+ turtle.jump();
+ }
+};
+// Main game loop
+game.update = function () {
+ if (gameState === 'playing') {
+ // Spawn spikes
+ if (LK.ticks - lastSpikeTime > spikeInterval) {
+ var spike = game.addChild(new Spike());
+ spike.x = 2048 + 100;
+ spike.y = ground.y;
+ spikes.push(spike);
+ lastSpikeTime = LK.ticks;
+ // Increase difficulty
+ if (spikeInterval > minSpikeInterval) {
+ spikeInterval -= 20;
+ }
+ }
+ // Update spikes and check collisions
+ for (var i = spikes.length - 1; i >= 0; i--) {
+ var spike = spikes[i];
+ // Remove off-screen spikes
+ if (spike.x < -100) {
+ spike.destroy();
+ spikes.splice(i, 1);
+ continue;
+ }
+ // Check if spike was passed for scoring
+ if (!spike.passed && spike.x < turtle.x) {
+ spike.passed = true;
+ gameScore++;
+ scoreText.setText(gameScore);
+ }
+ // Check collision with turtle
+ if (turtle && turtle.intersects(spike)) {
+ gameOver();
+ return;
+ }
+ }
+ }
+};
+// Initialize main menu
+createMainMenu();
\ No newline at end of file
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