User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 600
User prompt
Final score 100 olunca oyun bitsin sevinç gösterisi olsun dinozor kurtulsun. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Dinozor daha yükseğe zıplasın
User prompt
Dinozor büyük olsun
User prompt
Final skoru 300 olunca oyun bitsin dinozorun hayatını kurtarıyım ve bir sevinç gösterisi olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
2071 yılı seçeneğini seçtiğimiz zaman gece İstanbul temalı gelişmiş bir şehir teması olacak ve ay yıldız sembolü olacak gece olarak tasarla
User prompt
2071 gelecek şehri gece olarak tasarla gelişmiş şehir İstanbul teması olarak tasarla ve yukarda türk sembolü olsun robotlar olsun
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'jump')' in or related to this line: 'player.jump();' Line Number: 393
User prompt
Oyun başlamadan önce bize iki seçenek bir gündüz teması m.ö. 3000 yılına uygun tema ve seçenek olsun ikinci seçenek ise 2071 yılında geçsin robotlar ve gökdelenler olsun gece teması olsun ve yukarda türk bayrağı sembolü olsun
User prompt
Gece temasını sil gündüz teması yap m.ö. 3000 yılına uygun bir tema tasarla
User prompt
Gece şehirli bölümünü sil yıl 2070 gelişmiş şehir ve yapay zeka teknoljisi ile şehir tasarla teması olsun
User prompt
Gece bölümünü yap şehirli bölümünüde yap temasını yap
User prompt
Player büyük olsun birazdaha ve daha yükseğe zıplasın
Code edit (1 edits merged)
Please save this source code
User prompt
Turtle Trouble
Initial prompt
Great choice! Here's a short and clear concept for a Super Mario–style 2D platformer game with turtles, written in English: --- Game Title: Turtle Trouble Genre: 2D Side-Scroller / Platformer Description: Jump, run, and survive in this classic 2D platformer! Players control a character who must jump over moving turtles to avoid being caught. If a turtle touches the player — Game Over. Gameplay Features: Classic Mario-style side-scrolling Jump over turtles or fall behind them Collect coins and stars for bonus points Increasing speed and difficulty as levels go on One-touch or arrow-key controls Game Over Condition: 👉 If a turtle touches the player — you lose! Why It Works: Simple, nostalgic platformer fun Fast-paced and addictive Easy to learn, hard to master Great for mobile or web Monetize with ads and level unlocks Technology: Unity 2D C# scripting Mobile and Web compatible --- Would you like a sample level design or character art idea next?
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BackgroundStar = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star_bg', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -0.3; self.twinkleTimer = Math.random() * 100; self.update = function () { self.x += self.speed; self.twinkleTimer += 0.05; starGraphics.alpha = 0.3 + Math.sin(self.twinkleTimer) * 0.7; }; return self; }); var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -0.5; // Very slow parallax self.floatTimer = Math.random() * 100; self.update = function () { self.x += self.speed; self.floatTimer += 0.02; cloudGraphics.y = Math.sin(self.floatTimer) * 20; }; return self; }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.value = 10; self.bobOffset = 0; self.update = function () { self.x += self.speed; // Add bobbing animation self.bobOffset += 0.1; coinGraphics.y = Math.sin(self.bobOffset) * 10; }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 1.0 }); self.velocityY = 0; self.isJumping = false; self.jumpForce = -35; self.gravity = 1.2; self.groundY = 2532; // Ground level self.update = function () { // Apply gravity self.velocityY += self.gravity; self.y += self.velocityY; // Check ground collision if (self.y >= self.groundY) { self.y = self.groundY; self.velocityY = 0; self.isJumping = false; } }; self.jump = function () { if (!self.isJumping) { self.velocityY = self.jumpForce; self.isJumping = true; LK.getSound('jump').play(); } }; return self; }); var Pyramid = Container.expand(function () { var self = Container.call(this); var pyramidType = Math.floor(Math.random() * 3) + 1; var pyramidGraphics = self.attachAsset('pyramid' + pyramidType, { anchorX: 0.5, anchorY: 1.0 }); self.speed = -2; // Slower parallax speed // Add stone blocks around pyramid for (var i = 0; i < 5; i++) { if (Math.random() > 0.4) { var stoneBlock = self.attachAsset('stone_block', { anchorX: 0.5, anchorY: 0.5 }); stoneBlock.x = (Math.random() - 0.5) * pyramidGraphics.width * 1.2; stoneBlock.y = -Math.random() * 100; } } // Add palm trees around pyramid if (Math.random() > 0.3) { var palmTrunk = self.attachAsset('palm_trunk', { anchorX: 0.5, anchorY: 1.0 }); var palmLeaves = self.attachAsset('palm_leaves', { anchorX: 0.5, anchorY: 0.5 }); palmTrunk.x = (Math.random() - 0.5) * pyramidGraphics.width * 1.5; palmTrunk.y = 0; palmLeaves.x = palmTrunk.x; palmLeaves.y = palmTrunk.y - palmTrunk.height; } self.update = function () { self.x += self.speed; }; return self; }); var Robot = Container.expand(function () { var self = Container.call(this); var robotGraphics = self.attachAsset('robot', { anchorX: 0.5, anchorY: 1.0 }); self.speed = -8; self.groundY = 2532; // Add neon lights for (var i = 0; i < 3; i++) { var light = self.attachAsset('neon_light', { anchorX: 0.5, anchorY: 0.5 }); light.x = (Math.random() - 0.5) * 80; light.y = -Math.random() * 60 - 10; } self.update = function () { self.x += self.speed; }; return self; }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.value = 50; self.rotationSpeed = 0.1; self.update = function () { self.x += self.speed; starGraphics.rotation += self.rotationSpeed; }; return self; }); var Tower = Container.expand(function () { var self = Container.call(this); var towerType = Math.floor(Math.random() * 3) + 1; var towerGraphics = self.attachAsset('tower' + towerType, { anchorX: 0.5, anchorY: 1.0 }); self.speed = -2; // Add neon lights to tower for (var i = 0; i < 8; i++) { if (Math.random() > 0.3) { var light = self.attachAsset('neon_light', { anchorX: 0.5, anchorY: 0.5 }); light.x = (Math.random() - 0.5) * towerGraphics.width; light.y = -Math.random() * towerGraphics.height; } } self.update = function () { self.x += self.speed; }; return self; }); var TurkishFlag = Container.expand(function () { var self = Container.call(this); var flagGraphics = self.attachAsset('turkish_flag', { anchorX: 0.5, anchorY: 0.5 }); var moon = self.attachAsset('flag_moon', { anchorX: 0.5, anchorY: 0.5 }); var star = self.attachAsset('flag_star', { anchorX: 0.5, anchorY: 0.5 }); moon.x = -15; moon.y = 0; star.x = -5; star.y = 0; star.rotation = 0.785; // 45 degrees self.waveTimer = 0; self.update = function () { self.waveTimer += 0.1; flagGraphics.skew.x = Math.sin(self.waveTimer) * 0.05; }; return self; }); var Turtle = Container.expand(function () { var self = Container.call(this); var turtleGraphics = self.attachAsset('turtle', { anchorX: 0.5, anchorY: 1.0 }); self.speed = -8; self.groundY = 2532; self.update = function () { self.x += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Futuristic theme assets // Game variables var gameSpeed = 8; var spawnTimer = 0; var difficultyTimer = 0; var distance = 0; var scoreMultiplier = 1; // Theme selection variables var gameStarted = false; var selectedTheme = null; // 'ancient' or 'futuristic' var themeSelectionUI = null; // Game objects var player; var ground; var sun; var turtles = []; var coins = []; var stars = []; var pyramids = []; var clouds = []; // UI elements var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var distanceTxt = new Text2('0m', { size: 80, fill: 0xFFFFFF }); distanceTxt.anchor.set(1, 0); LK.gui.topRight.addChild(distanceTxt); // Initialize game elements function initializeGame() { // Create sun sun = game.addChild(LK.getAsset('sun', { anchorX: 0.5, anchorY: 0.5 })); sun.x = 1700; sun.y = 400; // Create background clouds for (var i = 0; i < 15; i++) { var cloud = new Cloud(); cloud.x = Math.random() * 2500; cloud.y = Math.random() * 600 + 200; clouds.push(cloud); game.addChild(cloud); } // Create initial pyramids for (var i = 0; i < 8; i++) { var pyramid = new Pyramid(); pyramid.x = i * 300 + Math.random() * 100; pyramid.y = 2732; pyramids.push(pyramid); game.addChild(pyramid); } // Create ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; // Create player player = game.addChild(new Player()); player.x = 300; player.y = 2532; // Start background music LK.playMusic('bgmusic'); } // Spawn enemy (turtle or robot based on theme) function spawnTurtle() { if (selectedTheme === 'ancient') { var turtle = new Turtle(); turtle.x = 2200; turtle.y = 2532; turtle.speed = -(gameSpeed + Math.random() * 4); turtles.push(turtle); game.addChild(turtle); } else if (selectedTheme === 'futuristic') { var robot = new Robot(); robot.x = 2200; robot.y = 2532; robot.speed = -(gameSpeed + Math.random() * 4); turtles.push(robot); // Reuse turtles array for robots game.addChild(robot); } } // Spawn coin function spawnCoin() { var coin = new Coin(); coin.x = 2200; coin.y = 2400 - Math.random() * 300; coin.speed = -gameSpeed; coins.push(coin); game.addChild(coin); } // Spawn star function spawnStar() { var star = new Star(); star.x = 2200; star.y = 2300 - Math.random() * 200; star.speed = -gameSpeed; stars.push(star); game.addChild(star); } // Spawn background structure (pyramid or tower based on theme) function spawnPyramid() { if (selectedTheme === 'ancient') { var pyramid = new Pyramid(); pyramid.x = 2200; pyramid.y = 2732; pyramids.push(pyramid); game.addChild(pyramid); } else if (selectedTheme === 'futuristic') { var tower = new Tower(); tower.x = 2200; tower.y = 2732; pyramids.push(tower); // Reuse pyramids array for towers game.addChild(tower); } } // Touch controls game.down = function (x, y, obj) { player.jump(); }; // Main game loop game.update = function () { // Only run game logic if game has started if (!gameStarted) return; // Update distance distance += gameSpeed / 10; distanceTxt.setText(Math.floor(distance) + 'm'); // Increase difficulty over time difficultyTimer++; if (difficultyTimer % 1800 === 0) { // Every 30 seconds gameSpeed += 0.5; } // Spawn enemies and collectibles spawnTimer++; // Spawn turtles if (spawnTimer % 120 === 0) { spawnTurtle(); } // Spawn coins if (spawnTimer % 180 === 0) { spawnCoin(); } // Spawn stars (less frequent) if (spawnTimer % 480 === 0) { spawnStar(); } // Spawn pyramids for background if (spawnTimer % 350 === 0) { spawnPyramid(); } // Update and check turtles for (var i = turtles.length - 1; i >= 0; i--) { var turtle = turtles[i]; // Remove if off screen if (turtle.x < -100) { turtle.destroy(); turtles.splice(i, 1); continue; } // Check collision with player if (turtle.intersects(player)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } // Update and check coins for (var i = coins.length - 1; i >= 0; i--) { var coin = coins[i]; // Remove if off screen if (coin.x < -100) { coin.destroy(); coins.splice(i, 1); continue; } // Check collection if (coin.intersects(player)) { LK.setScore(LK.getScore() + coin.value * scoreMultiplier); scoreTxt.setText(LK.getScore()); LK.getSound('coin').play(); coin.destroy(); coins.splice(i, 1); } } // Update and check stars for (var i = stars.length - 1; i >= 0; i--) { var star = stars[i]; // Remove if off screen if (star.x < -100) { star.destroy(); stars.splice(i, 1); continue; } // Check collection if (star.intersects(player)) { LK.setScore(LK.getScore() + star.value * scoreMultiplier); scoreTxt.setText(LK.getScore()); scoreMultiplier += 0.1; LK.getSound('star').play(); LK.effects.flashObject(star, 0xFFFFFF, 500); star.destroy(); stars.splice(i, 1); } } // Update and cleanup pyramids for (var i = pyramids.length - 1; i >= 0; i--) { var pyramid = pyramids[i]; if (pyramid.x < -400) { pyramid.destroy(); pyramids.splice(i, 1); } } // Update and cleanup clouds/stars for (var i = clouds.length - 1; i >= 0; i--) { var cloud = clouds[i]; if (cloud.x < -150) { cloud.destroy(); clouds.splice(i, 1); // Spawn new cloud or star based on theme if (selectedTheme === 'ancient') { var newCloud = new Cloud(); newCloud.x = 2100 + Math.random() * 200; newCloud.y = Math.random() * 600 + 200; clouds.push(newCloud); game.addChild(newCloud); } else if (selectedTheme === 'futuristic') { var newStar = new BackgroundStar(); newStar.x = 2100 + Math.random() * 200; newStar.y = Math.random() * 1000 + 200; clouds.push(newStar); game.addChild(newStar); } } } // Add distance to score LK.setScore(LK.getScore() + Math.floor(gameSpeed / 10)); scoreTxt.setText(LK.getScore()); }; // Create theme selection screen function createThemeSelection() { // Create selection container themeSelectionUI = game.addChild(new Container()); // Title var titleTxt = new Text2('TEMA SEÇ / CHOOSE THEME', { size: 120, fill: 0x000000 }); titleTxt.anchor.set(0.5, 0.5); titleTxt.x = 1024; titleTxt.y = 800; themeSelectionUI.addChild(titleTxt); // Ancient theme button var ancientBtn = themeSelectionUI.addChild(new Container()); var ancientBg = ancientBtn.attachAsset('pyramid1', { anchorX: 0.5, anchorY: 0.5 }); var ancientTxt = new Text2('M.Ö. 3000\nANTİK MISIR', { size: 80, fill: 0x000000 }); ancientTxt.anchor.set(0.5, 0.5); ancientBtn.addChild(ancientTxt); ancientBtn.x = 600; ancientBtn.y = 1400; // Futuristic theme button var futuristicBtn = themeSelectionUI.addChild(new Container()); var futuristicBg = futuristicBtn.attachAsset('tower1', { anchorX: 0.5, anchorY: 0.5 }); var futuristicTxt = new Text2('2071\nGELECEK ŞEHRİ', { size: 80, fill: 0x00ffff }); futuristicTxt.anchor.set(0.5, 0.5); futuristicBtn.addChild(futuristicTxt); futuristicBtn.x = 1448; futuristicBtn.y = 1400; // Event handlers ancientBtn.down = function () { selectedTheme = 'ancient'; startGameWithTheme(); }; futuristicBtn.down = function () { selectedTheme = 'futuristic'; startGameWithTheme(); }; } // Start game with selected theme function startGameWithTheme() { if (themeSelectionUI) { themeSelectionUI.destroy(); themeSelectionUI = null; } gameStarted = true; initializeGame(); } // Modified initialization for themes function initializeAncientTheme() { // Set daytime background game.setBackgroundColor(0x87ceeb); // Create sun sun = game.addChild(LK.getAsset('sun', { anchorX: 0.5, anchorY: 0.5 })); sun.x = 1700; sun.y = 400; // Create background clouds for (var i = 0; i < 15; i++) { var cloud = new Cloud(); cloud.x = Math.random() * 2500; cloud.y = Math.random() * 600 + 200; clouds.push(cloud); game.addChild(cloud); } // Create initial pyramids for (var i = 0; i < 8; i++) { var pyramid = new Pyramid(); pyramid.x = i * 300 + Math.random() * 100; pyramid.y = 2732; pyramids.push(pyramid); game.addChild(pyramid); } // Create ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; } function initializeFuturisticTheme() { // Set night background game.setBackgroundColor(0x0a0a0a); // Create Turkish flag in the sky var turkishFlag = game.addChild(new TurkishFlag()); turkishFlag.x = 1700; turkishFlag.y = 400; // Create background stars for (var i = 0; i < 50; i++) { var star = new BackgroundStar(); star.x = Math.random() * 2500; star.y = Math.random() * 1000 + 200; clouds.push(star); // Reuse clouds array for stars game.addChild(star); } // Create initial towers for (var i = 0; i < 8; i++) { var tower = new Tower(); tower.x = i * 300 + Math.random() * 100; tower.y = 2732; pyramids.push(tower); // Reuse pyramids array for towers game.addChild(tower); } // Create futuristic ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; ground.tint = 0x333333; // Dark futuristic ground } // Create theme selection screen instead of initializing game createThemeSelection();
===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,23 @@
/****
* Classes
****/
+var BackgroundStar = Container.expand(function () {
+ var self = Container.call(this);
+ var starGraphics = self.attachAsset('star_bg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -0.3;
+ self.twinkleTimer = Math.random() * 100;
+ self.update = function () {
+ self.x += self.speed;
+ self.twinkleTimer += 0.05;
+ starGraphics.alpha = 0.3 + Math.sin(self.twinkleTimer) * 0.7;
+ };
+ return self;
+});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
@@ -107,8 +122,30 @@
self.x += self.speed;
};
return self;
});
+var Robot = Container.expand(function () {
+ var self = Container.call(this);
+ var robotGraphics = self.attachAsset('robot', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.speed = -8;
+ self.groundY = 2532;
+ // Add neon lights
+ for (var i = 0; i < 3; i++) {
+ var light = self.attachAsset('neon_light', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ light.x = (Math.random() - 0.5) * 80;
+ light.y = -Math.random() * 60 - 10;
+ }
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
@@ -122,8 +159,58 @@
starGraphics.rotation += self.rotationSpeed;
};
return self;
});
+var Tower = Container.expand(function () {
+ var self = Container.call(this);
+ var towerType = Math.floor(Math.random() * 3) + 1;
+ var towerGraphics = self.attachAsset('tower' + towerType, {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.speed = -2;
+ // Add neon lights to tower
+ for (var i = 0; i < 8; i++) {
+ if (Math.random() > 0.3) {
+ var light = self.attachAsset('neon_light', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ light.x = (Math.random() - 0.5) * towerGraphics.width;
+ light.y = -Math.random() * towerGraphics.height;
+ }
+ }
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
+var TurkishFlag = Container.expand(function () {
+ var self = Container.call(this);
+ var flagGraphics = self.attachAsset('turkish_flag', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var moon = self.attachAsset('flag_moon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var star = self.attachAsset('flag_star', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ moon.x = -15;
+ moon.y = 0;
+ star.x = -5;
+ star.y = 0;
+ star.rotation = 0.785; // 45 degrees
+ self.waveTimer = 0;
+ self.update = function () {
+ self.waveTimer += 0.1;
+ flagGraphics.skew.x = Math.sin(self.waveTimer) * 0.05;
+ };
+ return self;
+});
var Turtle = Container.expand(function () {
var self = Container.call(this);
var turtleGraphics = self.attachAsset('turtle', {
anchorX: 0.5,
@@ -146,14 +233,19 @@
/****
* Game Code
****/
+// Futuristic theme assets
// Game variables
var gameSpeed = 8;
var spawnTimer = 0;
var difficultyTimer = 0;
var distance = 0;
var scoreMultiplier = 1;
+// Theme selection variables
+var gameStarted = false;
+var selectedTheme = null; // 'ancient' or 'futuristic'
+var themeSelectionUI = null;
// Game objects
var player;
var ground;
var sun;
@@ -213,16 +305,25 @@
player.y = 2532;
// Start background music
LK.playMusic('bgmusic');
}
-// Spawn turtle enemy
+// Spawn enemy (turtle or robot based on theme)
function spawnTurtle() {
- var turtle = new Turtle();
- turtle.x = 2200;
- turtle.y = 2532;
- turtle.speed = -(gameSpeed + Math.random() * 4);
- turtles.push(turtle);
- game.addChild(turtle);
+ if (selectedTheme === 'ancient') {
+ var turtle = new Turtle();
+ turtle.x = 2200;
+ turtle.y = 2532;
+ turtle.speed = -(gameSpeed + Math.random() * 4);
+ turtles.push(turtle);
+ game.addChild(turtle);
+ } else if (selectedTheme === 'futuristic') {
+ var robot = new Robot();
+ robot.x = 2200;
+ robot.y = 2532;
+ robot.speed = -(gameSpeed + Math.random() * 4);
+ turtles.push(robot); // Reuse turtles array for robots
+ game.addChild(robot);
+ }
}
// Spawn coin
function spawnCoin() {
var coin = new Coin();
@@ -240,22 +341,32 @@
star.speed = -gameSpeed;
stars.push(star);
game.addChild(star);
}
-// Spawn pyramid
+// Spawn background structure (pyramid or tower based on theme)
function spawnPyramid() {
- var pyramid = new Pyramid();
- pyramid.x = 2200;
- pyramid.y = 2732;
- pyramids.push(pyramid);
- game.addChild(pyramid);
+ if (selectedTheme === 'ancient') {
+ var pyramid = new Pyramid();
+ pyramid.x = 2200;
+ pyramid.y = 2732;
+ pyramids.push(pyramid);
+ game.addChild(pyramid);
+ } else if (selectedTheme === 'futuristic') {
+ var tower = new Tower();
+ tower.x = 2200;
+ tower.y = 2732;
+ pyramids.push(tower); // Reuse pyramids array for towers
+ game.addChild(tower);
+ }
}
// Touch controls
game.down = function (x, y, obj) {
player.jump();
};
// Main game loop
game.update = function () {
+ // Only run game logic if game has started
+ if (!gameStarted) return;
// Update distance
distance += gameSpeed / 10;
distanceTxt.setText(Math.floor(distance) + 'm');
// Increase difficulty over time
@@ -343,24 +454,159 @@
pyramid.destroy();
pyramids.splice(i, 1);
}
}
- // Update and cleanup clouds
+ // Update and cleanup clouds/stars
for (var i = clouds.length - 1; i >= 0; i--) {
var cloud = clouds[i];
if (cloud.x < -150) {
cloud.destroy();
clouds.splice(i, 1);
- // Spawn new cloud
- var newCloud = new Cloud();
- newCloud.x = 2100 + Math.random() * 200;
- newCloud.y = Math.random() * 600 + 200;
- clouds.push(newCloud);
- game.addChild(newCloud);
+ // Spawn new cloud or star based on theme
+ if (selectedTheme === 'ancient') {
+ var newCloud = new Cloud();
+ newCloud.x = 2100 + Math.random() * 200;
+ newCloud.y = Math.random() * 600 + 200;
+ clouds.push(newCloud);
+ game.addChild(newCloud);
+ } else if (selectedTheme === 'futuristic') {
+ var newStar = new BackgroundStar();
+ newStar.x = 2100 + Math.random() * 200;
+ newStar.y = Math.random() * 1000 + 200;
+ clouds.push(newStar);
+ game.addChild(newStar);
+ }
}
}
// Add distance to score
LK.setScore(LK.getScore() + Math.floor(gameSpeed / 10));
scoreTxt.setText(LK.getScore());
};
-// Initialize the game
-initializeGame();
\ No newline at end of file
+// Create theme selection screen
+function createThemeSelection() {
+ // Create selection container
+ themeSelectionUI = game.addChild(new Container());
+ // Title
+ var titleTxt = new Text2('TEMA SEÇ / CHOOSE THEME', {
+ size: 120,
+ fill: 0x000000
+ });
+ titleTxt.anchor.set(0.5, 0.5);
+ titleTxt.x = 1024;
+ titleTxt.y = 800;
+ themeSelectionUI.addChild(titleTxt);
+ // Ancient theme button
+ var ancientBtn = themeSelectionUI.addChild(new Container());
+ var ancientBg = ancientBtn.attachAsset('pyramid1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var ancientTxt = new Text2('M.Ö. 3000\nANTİK MISIR', {
+ size: 80,
+ fill: 0x000000
+ });
+ ancientTxt.anchor.set(0.5, 0.5);
+ ancientBtn.addChild(ancientTxt);
+ ancientBtn.x = 600;
+ ancientBtn.y = 1400;
+ // Futuristic theme button
+ var futuristicBtn = themeSelectionUI.addChild(new Container());
+ var futuristicBg = futuristicBtn.attachAsset('tower1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var futuristicTxt = new Text2('2071\nGELECEK ŞEHRİ', {
+ size: 80,
+ fill: 0x00ffff
+ });
+ futuristicTxt.anchor.set(0.5, 0.5);
+ futuristicBtn.addChild(futuristicTxt);
+ futuristicBtn.x = 1448;
+ futuristicBtn.y = 1400;
+ // Event handlers
+ ancientBtn.down = function () {
+ selectedTheme = 'ancient';
+ startGameWithTheme();
+ };
+ futuristicBtn.down = function () {
+ selectedTheme = 'futuristic';
+ startGameWithTheme();
+ };
+}
+// Start game with selected theme
+function startGameWithTheme() {
+ if (themeSelectionUI) {
+ themeSelectionUI.destroy();
+ themeSelectionUI = null;
+ }
+ gameStarted = true;
+ initializeGame();
+}
+// Modified initialization for themes
+function initializeAncientTheme() {
+ // Set daytime background
+ game.setBackgroundColor(0x87ceeb);
+ // Create sun
+ sun = game.addChild(LK.getAsset('sun', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ sun.x = 1700;
+ sun.y = 400;
+ // Create background clouds
+ for (var i = 0; i < 15; i++) {
+ var cloud = new Cloud();
+ cloud.x = Math.random() * 2500;
+ cloud.y = Math.random() * 600 + 200;
+ clouds.push(cloud);
+ game.addChild(cloud);
+ }
+ // Create initial pyramids
+ for (var i = 0; i < 8; i++) {
+ var pyramid = new Pyramid();
+ pyramid.x = i * 300 + Math.random() * 100;
+ pyramid.y = 2732;
+ pyramids.push(pyramid);
+ game.addChild(pyramid);
+ }
+ // Create ground
+ ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1
+ }));
+ ground.x = 0;
+ ground.y = 2732;
+}
+function initializeFuturisticTheme() {
+ // Set night background
+ game.setBackgroundColor(0x0a0a0a);
+ // Create Turkish flag in the sky
+ var turkishFlag = game.addChild(new TurkishFlag());
+ turkishFlag.x = 1700;
+ turkishFlag.y = 400;
+ // Create background stars
+ for (var i = 0; i < 50; i++) {
+ var star = new BackgroundStar();
+ star.x = Math.random() * 2500;
+ star.y = Math.random() * 1000 + 200;
+ clouds.push(star); // Reuse clouds array for stars
+ game.addChild(star);
+ }
+ // Create initial towers
+ for (var i = 0; i < 8; i++) {
+ var tower = new Tower();
+ tower.x = i * 300 + Math.random() * 100;
+ tower.y = 2732;
+ pyramids.push(tower); // Reuse pyramids array for towers
+ game.addChild(tower);
+ }
+ // Create futuristic ground
+ ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1
+ }));
+ ground.x = 0;
+ ground.y = 2732;
+ ground.tint = 0x333333; // Dark futuristic ground
+}
+// Create theme selection screen instead of initializing game
+createThemeSelection();
\ No newline at end of file