User prompt
Let's name the game a desert adventure
User prompt
It didn't work, when you change the language, the level selection part is written in both languages and they are intertwined.
User prompt
And finally, when you change the language, the animations and texts in the main menu are intertwined and it is not nice.
User prompt
When the language is changed, the text in the main menu remains, if you fix them too
User prompt
and add language option to the game either English or Turkish
User prompt
and at the beginning of each section write "enter the door if it doesn't go left"
User prompt
and if he enters the door before all the treasures are collected, restart the level
User prompt
There is a small problem, it does not go left when you go a little further.
User prompt
doesnt jump it
User prompt
Ok, let's try something else. If we press up, the jump button will be removed. In other words, the longer we press on half of the screen, the more it will jump. There will be no left or right movement at the top of the screen.
User prompt
and there is a jump button in the middle, when you press it, he jumps, the more he presses it, the higher he jumps
User prompt
When you press the stop button, it will say main menu so we can go to the main menu from there
User prompt
If they can't get all the treasures, the level won't be completed. There should also be a main menu, play there and have levels, reach the completed levels in the levels, and when you press on the character, he/she will jump and the character will be happy when the game is over. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
do a 10 level and levels are hard
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = game.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 1392
Code edit (1 edits merged)
Please save this source code
User prompt
Mario's Treasure Quest
Initial prompt
ı do a like uncharted 3 but mario stile 5 different level in the game
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Enemy = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 1.0 }); self.velocityX = -2; self.velocityY = 0; self.direction = -1; self.defeated = false; self.update = function () { if (!self.defeated) { // Apply gravity self.velocityY += 1.2; // Move horizontally self.x += self.velocityX; self.y += self.velocityY; // Reset velocity Y when on ground (simplified) if (self.y >= 2732 - 160) { self.y = 2732 - 160; self.velocityY = 0; } } }; self.defeat = function () { if (!self.defeated) { self.defeated = true; self.visible = false; LK.setScore(LK.getScore() + 50); LK.getSound('defeat').play(); updateUI(); } }; self.reverseDirection = function () { self.velocityX *= -1; self.direction *= -1; }; return self; }); var Goal = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('goal', { anchorX: 0.5, anchorY: 1.0 }); self.reached = false; return self; }); var Ground = Container.expand(function (width) { var self = Container.call(this); var graphics = self.attachAsset('ground', { anchorX: 0, anchorY: 0, width: width || 200, height: 80 }); self.groundWidth = width || 200; self.groundHeight = 80; return self; }); var Platform = Container.expand(function (width, height) { var self = Container.call(this); var graphics = self.attachAsset('platform', { anchorX: 0, anchorY: 0, width: width || 200, height: height || 40 }); self.platformWidth = width || 200; self.platformHeight = height || 40; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 1.0 }); self.velocityX = 0; self.velocityY = 0; self.speed = 8; self.jumpPower = 25; self.onGround = false; self.facingRight = true; self.invulnerable = false; self.powerUpTimer = 0; self.update = function () { // Apply gravity self.velocityY += 1.2; // Update position self.x += self.velocityX; self.y += self.velocityY; // Handle power-up timer if (self.powerUpTimer > 0) { self.powerUpTimer--; if (self.powerUpTimer <= 0) { self.invulnerable = false; graphics.tint = 0xffffff; } } // Reset ground state self.onGround = false; // Apply friction self.velocityX *= 0.85; }; self.jump = function () { if (self.onGround) { self.velocityY = -self.jumpPower; self.onGround = false; LK.getSound('jump').play(); } }; self.moveLeft = function () { self.velocityX = -self.speed; if (self.facingRight) { self.facingRight = false; graphics.scaleX = -1; } }; self.moveRight = function () { self.velocityX = self.speed; if (!self.facingRight) { self.facingRight = true; graphics.scaleX = 1; } }; self.landOnGround = function () { self.onGround = true; self.velocityY = 0; }; self.collectTreasure = function () { treasuresCollected++; LK.setScore(LK.getScore() + 100); LK.getSound('collect').play(); updateUI(); }; self.collectPowerUp = function () { self.invulnerable = true; self.powerUpTimer = 300; // 5 seconds at 60fps graphics.tint = 0xffff00; LK.getSound('powerup').play(); }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('powerup', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.pulseOffset = 0; self.update = function () { if (!self.collected) { self.pulseOffset += 0.15; graphics.scaleX = 1 + Math.sin(self.pulseOffset) * 0.2; graphics.scaleY = 1 + Math.sin(self.pulseOffset) * 0.2; } }; self.collect = function () { if (!self.collected) { self.collected = true; self.visible = false; return true; } return false; }; return self; }); var Treasure = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('treasure', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.bobOffset = 0; self.update = function () { if (!self.collected) { self.bobOffset += 0.2; self.y += Math.sin(self.bobOffset) * 0.5; graphics.rotation += 0.05; } }; self.collect = function () { if (!self.collected) { self.collected = true; self.visible = false; return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state variables var currentLevel = storage.currentLevel || 1; var maxLevel = storage.maxLevel || 1; var treasuresCollected = 0; var totalTreasures = 0; var levelCompleted = false; var gameCamera = { x: 0, y: 0 }; // Game objects var player; var platforms = []; var grounds = []; var treasures = []; var enemies = []; var powerUps = []; var goal; // UI elements var scoreText; var levelText; var treasureText; var instructionText; // Level themes and colors var levelThemes = { 1: { name: "Desert Ruins", bg: 0xDEB887, groundColor: 0xD2691E }, 2: { name: "Underground Caverns", bg: 0x2F4F4F, groundColor: 0x696969 }, 3: { name: "Jungle Temple", bg: 0x228B22, groundColor: 0x8B4513 }, 4: { name: "Icy Mountains", bg: 0x4682B4, groundColor: 0xE6E6FA }, 5: { name: "Final Castle", bg: 0x4B0082, groundColor: 0x8B0000 } }; // Input handling var keys = { left: false, right: false, jump: false }; function initializeUI() { scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); scoreText.x = 120; scoreText.y = 20; LK.gui.topLeft.addChild(scoreText); levelText = new Text2('Level 1', { size: 60, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0); LK.gui.top.addChild(levelText); treasureText = new Text2('Treasures: 0/0', { size: 60, fill: 0xFFFFFF }); treasureText.anchor.set(1, 0); treasureText.x = -20; treasureText.y = 20; LK.gui.topRight.addChild(treasureText); instructionText = new Text2('Tap to move and jump!', { size: 80, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0.5); LK.gui.center.addChild(instructionText); // Hide instruction after 3 seconds LK.setTimeout(function () { instructionText.visible = false; }, 3000); } function updateUI() { scoreText.setText('Score: ' + LK.getScore()); levelText.setText('Level ' + currentLevel + ': ' + levelThemes[currentLevel].name); treasureText.setText('Treasures: ' + treasuresCollected + '/' + totalTreasures); } function createLevel(levelNum) { // Clear existing objects clearLevel(); // Set theme var theme = levelThemes[levelNum]; game.setBackgroundColor(theme.bg); // Create player player = game.addChild(new Player()); player.x = 200; player.y = 2732 - 200; // Create level-specific layout if (levelNum === 1) { createDesertLevel(); } else if (levelNum === 2) { createCaveLevel(); } else if (levelNum === 3) { createJungleLevel(); } else if (levelNum === 4) { createMountainLevel(); } else if (levelNum === 5) { createCastleLevel(); } // Create goal at the end goal = game.addChild(new Goal()); goal.x = 4500; goal.y = 2732 - 80; // Reset level state treasuresCollected = 0; levelCompleted = false; gameCamera.x = 0; updateUI(); } function createDesertLevel() { // Ground segments for (var i = 0; i < 25; i++) { var ground = game.addChild(new Ground(200)); ground.x = i * 200; ground.y = 2732 - 80; grounds.push(ground); } // Platforms var platformData = [{ x: 400, y: 2400, w: 200, h: 40 }, { x: 800, y: 2200, w: 150, h: 40 }, { x: 1200, y: 2000, w: 200, h: 40 }, { x: 1600, y: 2300, w: 180, h: 40 }, { x: 2000, y: 2100, w: 200, h: 40 }, { x: 2500, y: 2400, w: 150, h: 40 }, { x: 2900, y: 2200, w: 200, h: 40 }, { x: 3400, y: 2000, w: 180, h: 40 }, { x: 3800, y: 2300, w: 200, h: 40 }, { x: 4200, y: 2100, w: 150, h: 40 }]; for (var i = 0; i < platformData.length; i++) { var p = platformData[i]; var platform = game.addChild(new Platform(p.w, p.h)); platform.x = p.x; platform.y = p.y; platforms.push(platform); } // Treasures var treasurePositions = [{ x: 500, y: 2350 }, { x: 900, y: 2150 }, { x: 1300, y: 1950 }, { x: 1700, y: 2250 }, { x: 2100, y: 2050 }, { x: 2600, y: 2350 }, { x: 3000, y: 2150 }, { x: 3500, y: 1950 }, { x: 3900, y: 2250 }]; for (var i = 0; i < treasurePositions.length; i++) { var t = treasurePositions[i]; var treasure = game.addChild(new Treasure()); treasure.x = t.x; treasure.y = t.y; treasures.push(treasure); } // Enemies var enemyPositions = [{ x: 1000, y: 2732 - 160 }, { x: 1800, y: 2732 - 160 }, { x: 2700, y: 2732 - 160 }, { x: 3600, y: 2732 - 160 }]; for (var i = 0; i < enemyPositions.length; i++) { var e = enemyPositions[i]; var enemy = game.addChild(new Enemy()); enemy.x = e.x; enemy.y = e.y; enemies.push(enemy); } // Power-ups var powerUp = game.addChild(new PowerUp()); powerUp.x = 1500; powerUp.y = 1950; powerUps.push(powerUp); totalTreasures = treasures.length; } function createCaveLevel() { // Similar structure but different layout for cave theme for (var i = 0; i < 25; i++) { var ground = game.addChild(new Ground(200)); ground.x = i * 200; ground.y = 2732 - 80; grounds.push(ground); } // More complex platforming for cave level var platformData = [{ x: 300, y: 2500, w: 150, h: 40 }, { x: 600, y: 2300, w: 120, h: 40 }, { x: 900, y: 2100, w: 150, h: 40 }, { x: 1300, y: 2400, w: 180, h: 40 }, { x: 1700, y: 2200, w: 150, h: 40 }, { x: 2100, y: 2000, w: 200, h: 40 }, { x: 2600, y: 2300, w: 150, h: 40 }, { x: 3000, y: 2100, w: 180, h: 40 }, { x: 3500, y: 2400, w: 150, h: 40 }, { x: 3900, y: 2200, w: 200, h: 40 }, { x: 4300, y: 2000, w: 150, h: 40 }]; for (var i = 0; i < platformData.length; i++) { var p = platformData[i]; var platform = game.addChild(new Platform(p.w, p.h)); platform.x = p.x; platform.y = p.y; platforms.push(platform); } // More treasures in cave var treasurePositions = [{ x: 400, y: 2450 }, { x: 700, y: 2250 }, { x: 1000, y: 2050 }, { x: 1400, y: 2350 }, { x: 1800, y: 2150 }, { x: 2200, y: 1950 }, { x: 2700, y: 2250 }, { x: 3100, y: 2050 }, { x: 3600, y: 2350 }, { x: 4000, y: 2150 }, { x: 4400, y: 1950 }]; for (var i = 0; i < treasurePositions.length; i++) { var t = treasurePositions[i]; var treasure = game.addChild(new Treasure()); treasure.x = t.x; treasure.y = t.y; treasures.push(treasure); } // More enemies in cave var enemyPositions = [{ x: 800, y: 2732 - 160 }, { x: 1500, y: 2732 - 160 }, { x: 2300, y: 2732 - 160 }, { x: 3200, y: 2732 - 160 }, { x: 4100, y: 2732 - 160 }]; for (var i = 0; i < enemyPositions.length; i++) { var e = enemyPositions[i]; var enemy = game.addChild(new Enemy()); enemy.x = e.x; enemy.y = e.y; enemies.push(enemy); } // Multiple power-ups var powerUpPositions = [{ x: 1200, y: 2050 }, { x: 2800, y: 2050 }]; for (var i = 0; i < powerUpPositions.length; i++) { var p = powerUpPositions[i]; var powerUp = game.addChild(new PowerUp()); powerUp.x = p.x; powerUp.y = p.y; powerUps.push(powerUp); } totalTreasures = treasures.length; } function createJungleLevel() { // Ground with gaps for jungle var groundSegments = [{ x: 0, w: 400 }, { x: 600, w: 300 }, { x: 1100, w: 250 }, { x: 1500, w: 400 }, { x: 2100, w: 300 }, { x: 2600, w: 400 }, { x: 3200, w: 300 }, { x: 3700, w: 400 }, { x: 4300, w: 500 }]; for (var i = 0; i < groundSegments.length; i++) { var seg = groundSegments[i]; var ground = game.addChild(new Ground(seg.w)); ground.x = seg.x; ground.y = 2732 - 80; grounds.push(ground); } // Vine-like platforms for jungle var platformData = [{ x: 450, y: 2400, w: 100, h: 40 }, { x: 750, y: 2300, w: 120, h: 40 }, { x: 950, y: 2500, w: 100, h: 40 }, { x: 1350, y: 2200, w: 100, h: 40 }, { x: 1650, y: 2400, w: 120, h: 40 }, { x: 1950, y: 2100, w: 100, h: 40 }, { x: 2450, y: 2300, w: 100, h: 40 }, { x: 2850, y: 2500, w: 120, h: 40 }, { x: 3050, y: 2200, w: 100, h: 40 }, { x: 3550, y: 2400, w: 120, h: 40 }, { x: 3950, y: 2100, w: 100, h: 40 }]; for (var i = 0; i < platformData.length; i++) { var p = platformData[i]; var platform = game.addChild(new Platform(p.w, p.h)); platform.x = p.x; platform.y = p.y; platforms.push(platform); } // Hidden treasures in jungle var treasurePositions = [{ x: 500, y: 2350 }, { x: 800, y: 2250 }, { x: 1000, y: 2450 }, { x: 1400, y: 2150 }, { x: 1700, y: 2350 }, { x: 2000, y: 2050 }, { x: 2500, y: 2250 }, { x: 2900, y: 2450 }, { x: 3100, y: 2150 }, { x: 3600, y: 2350 }, { x: 4000, y: 2050 }, { x: 4500, y: 2600 }]; for (var i = 0; i < treasurePositions.length; i++) { var t = treasurePositions[i]; var treasure = game.addChild(new Treasure()); treasure.x = t.x; treasure.y = t.y; treasures.push(treasure); } // Jungle enemies var enemyPositions = [{ x: 700, y: 2732 - 160 }, { x: 1200, y: 2732 - 160 }, { x: 1800, y: 2732 - 160 }, { x: 2800, y: 2732 - 160 }, { x: 3800, y: 2732 - 160 }]; for (var i = 0; i < enemyPositions.length; i++) { var e = enemyPositions[i]; var enemy = game.addChild(new Enemy()); enemy.x = e.x; enemy.y = e.y; enemies.push(enemy); } // Power-ups var powerUpPositions = [{ x: 1350, y: 2150 }, { x: 2900, y: 2150 }, { x: 3550, y: 2150 }]; for (var i = 0; i < powerUpPositions.length; i++) { var p = powerUpPositions[i]; var powerUp = game.addChild(new PowerUp()); powerUp.x = p.x; powerUp.y = p.y; powerUps.push(powerUp); } totalTreasures = treasures.length; } function createMountainLevel() { // Icy platforms at different heights for (var i = 0; i < 20; i++) { var ground = game.addChild(new Ground(250)); ground.x = i * 250; ground.y = 2732 - 80; grounds.push(ground); } // Mountain-like ascending platforms var platformData = [{ x: 300, y: 2500, w: 150, h: 40 }, { x: 600, y: 2350, w: 140, h: 40 }, { x: 900, y: 2200, w: 150, h: 40 }, { x: 1250, y: 2050, w: 140, h: 40 }, { x: 1600, y: 1900, w: 150, h: 40 }, { x: 1950, y: 2000, w: 140, h: 40 }, { x: 2300, y: 2150, w: 150, h: 40 }, { x: 2650, y: 2000, w: 140, h: 40 }, { x: 3000, y: 1850, w: 150, h: 40 }, { x: 3350, y: 2000, w: 140, h: 40 }, { x: 3700, y: 2150, w: 150, h: 40 }, { x: 4050, y: 2000, w: 140, h: 40 }]; for (var i = 0; i < platformData.length; i++) { var p = platformData[i]; var platform = game.addChild(new Platform(p.w, p.h)); platform.x = p.x; platform.y = p.y; platforms.push(platform); } // Mountain treasures var treasurePositions = [{ x: 375, y: 2450 }, { x: 670, y: 2300 }, { x: 975, y: 2150 }, { x: 1320, y: 2000 }, { x: 1675, y: 1850 }, { x: 2020, y: 1950 }, { x: 2375, y: 2100 }, { x: 2720, y: 1950 }, { x: 3075, y: 1800 }, { x: 3420, y: 1950 }, { x: 3775, y: 2100 }, { x: 4120, y: 1950 }, { x: 4400, y: 2600 }]; for (var i = 0; i < treasurePositions.length; i++) { var t = treasurePositions[i]; var treasure = game.addChild(new Treasure()); treasure.x = t.x; treasure.y = t.y; treasures.push(treasure); } // Mountain enemies var enemyPositions = [{ x: 500, y: 2732 - 160 }, { x: 1100, y: 2732 - 160 }, { x: 1700, y: 2732 - 160 }, { x: 2400, y: 2732 - 160 }, { x: 3100, y: 2732 - 160 }, { x: 3800, y: 2732 - 160 }]; for (var i = 0; i < enemyPositions.length; i++) { var e = enemyPositions[i]; var enemy = game.addChild(new Enemy()); enemy.x = e.x; enemy.y = e.y; enemies.push(enemy); } // Power-ups var powerUpPositions = [{ x: 1320, y: 1950 }, { x: 2720, y: 1900 }, { x: 3775, y: 1950 }]; for (var i = 0; i < powerUpPositions.length; i++) { var p = powerUpPositions[i]; var powerUp = game.addChild(new PowerUp()); powerUp.x = p.x; powerUp.y = p.y; powerUps.push(powerUp); } totalTreasures = treasures.length; } function createCastleLevel() { // Castle ground segments for (var i = 0; i < 30; i++) { var ground = game.addChild(new Ground(200)); ground.x = i * 200; ground.y = 2732 - 80; grounds.push(ground); } // Castle-like platform structure var platformData = [{ x: 300, y: 2400, w: 200, h: 40 }, { x: 600, y: 2200, w: 150, h: 40 }, { x: 900, y: 2000, w: 180, h: 40 }, { x: 1200, y: 1800, w: 150, h: 40 }, { x: 1500, y: 2300, w: 200, h: 40 }, { x: 1800, y: 2100, w: 150, h: 40 }, { x: 2100, y: 1900, w: 180, h: 40 }, { x: 2400, y: 2200, w: 150, h: 40 }, { x: 2700, y: 2000, w: 200, h: 40 }, { x: 3000, y: 1800, w: 150, h: 40 }, { x: 3300, y: 2100, w: 180, h: 40 }, { x: 3600, y: 1900, w: 150, h: 40 }, { x: 3900, y: 2200, w: 200, h: 40 }, { x: 4200, y: 2000, w: 150, h: 40 }, { x: 4500, y: 1800, w: 180, h: 40 }]; for (var i = 0; i < platformData.length; i++) { var p = platformData[i]; var platform = game.addChild(new Platform(p.w, p.h)); platform.x = p.x; platform.y = p.y; platforms.push(platform); } // Final castle treasures var treasurePositions = [{ x: 400, y: 2350 }, { x: 675, y: 2150 }, { x: 990, y: 1950 }, { x: 1275, y: 1750 }, { x: 1600, y: 2250 }, { x: 1875, y: 2050 }, { x: 2190, y: 1850 }, { x: 2475, y: 2150 }, { x: 2800, y: 1950 }, { x: 3075, y: 1750 }, { x: 3390, y: 2050 }, { x: 3675, y: 1850 }, { x: 4000, y: 2150 }, { x: 4275, y: 1950 }, { x: 4590, y: 1750 }]; for (var i = 0; i < treasurePositions.length; i++) { var t = treasurePositions[i]; var treasure = game.addChild(new Treasure()); treasure.x = t.x; treasure.y = t.y; treasures.push(treasure); } // Final castle enemies var enemyPositions = [{ x: 800, y: 2732 - 160 }, { x: 1300, y: 2732 - 160 }, { x: 1900, y: 2732 - 160 }, { x: 2500, y: 2732 - 160 }, { x: 3100, y: 2732 - 160 }, { x: 3700, y: 2732 - 160 }, { x: 4300, y: 2732 - 160 }]; for (var i = 0; i < enemyPositions.length; i++) { var e = enemyPositions[i]; var enemy = game.addChild(new Enemy()); enemy.x = e.x; enemy.y = e.y; enemies.push(enemy); } // Multiple power-ups for final level var powerUpPositions = [{ x: 1275, y: 1700 }, { x: 2190, y: 1800 }, { x: 3075, y: 1700 }, { x: 4275, y: 1900 }]; for (var i = 0; i < powerUpPositions.length; i++) { var p = powerUpPositions[i]; var powerUp = game.addChild(new PowerUp()); powerUp.x = p.x; powerUp.y = p.y; powerUps.push(powerUp); } totalTreasures = treasures.length; } function clearLevel() { // Clear all game objects for (var i = 0; i < platforms.length; i++) { platforms[i].destroy(); } platforms = []; for (var i = 0; i < grounds.length; i++) { grounds[i].destroy(); } grounds = []; for (var i = 0; i < treasures.length; i++) { treasures[i].destroy(); } treasures = []; for (var i = 0; i < enemies.length; i++) { enemies[i].destroy(); } enemies = []; for (var i = 0; i < powerUps.length; i++) { powerUps[i].destroy(); } powerUps = []; if (goal) { goal.destroy(); goal = null; } if (player) { player.destroy(); player = null; } } function checkCollisions() { // Player vs ground collision for (var i = 0; i < grounds.length; i++) { var ground = grounds[i]; if (player.x + 40 > ground.x && player.x - 40 < ground.x + ground.groundWidth && player.y > ground.y - 10 && player.y < ground.y + ground.groundHeight + 10 && player.velocityY > 0) { player.y = ground.y; player.landOnGround(); } } // Player vs platform collision for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; if (player.x + 40 > platform.x && player.x - 40 < platform.x + platform.platformWidth && player.y > platform.y - 10 && player.y < platform.y + platform.platformHeight + 10 && player.velocityY > 0) { player.y = platform.y; player.landOnGround(); } } // Player vs treasure collision for (var i = 0; i < treasures.length; i++) { var treasure = treasures[i]; if (!treasure.collected && player.intersects(treasure)) { if (treasure.collect()) { player.collectTreasure(); } } } // Player vs enemy collision for (var i = 0; i < enemies.length; i++) { var enemy = enemies[i]; if (!enemy.defeated && player.intersects(enemy)) { if (player.invulnerable) { enemy.defeat(); } else { // Player takes damage LK.effects.flashScreen(0xff0000, 500); player.x = 200; // Reset position player.y = 2732 - 200; player.velocityX = 0; player.velocityY = 0; } } } // Player vs power-up collision for (var i = 0; i < powerUps.length; i++) { var powerUp = powerUps[i]; if (!powerUp.collected && player.intersects(powerUp)) { if (powerUp.collect()) { player.collectPowerUp(); } } } // Player vs goal collision if (goal && !goal.reached && player.intersects(goal)) { goal.reached = true; levelCompleted = true; completeLevel(); } // Enemy vs platform collision (simple AI) for (var i = 0; i < enemies.length; i++) { var enemy = enemies[i]; if (!enemy.defeated) { var onPlatform = false; // Check if enemy is on ground for (var j = 0; j < grounds.length; j++) { var ground = grounds[j]; if (enemy.x + 30 > ground.x && enemy.x - 30 < ground.x + ground.groundWidth && enemy.y >= ground.y - 10 && enemy.y <= ground.y + 10) { enemy.y = ground.y; enemy.velocityY = 0; onPlatform = true; break; } } // Check if enemy is on platform if (!onPlatform) { for (var j = 0; j < platforms.length; j++) { var platform = platforms[j]; if (enemy.x + 30 > platform.x && enemy.x - 30 < platform.x + platform.platformWidth && enemy.y >= platform.y - 10 && enemy.y <= platform.y + 10) { enemy.y = platform.y; enemy.velocityY = 0; onPlatform = true; break; } } } // Reverse direction at edges if (enemy.x <= 0 || enemy.x >= 5000) { enemy.reverseDirection(); } } } // Keep player in bounds if (player.x < 0) player.x = 0; if (player.x > 5000) player.x = 5000; // Check if player falls off screen if (player.y > 2732 + 200) { player.x = 200; player.y = 2732 - 200; player.velocityX = 0; player.velocityY = 0; LK.effects.flashScreen(0xff0000, 500); } } function updateCamera() { // Follow player with camera var targetX = -player.x + 1024; // Center player horizontally gameCamera.x += (targetX - gameCamera.x) * 0.1; // Smooth camera movement // Clamp camera if (gameCamera.x > 0) gameCamera.x = 0; if (gameCamera.x < -3500) gameCamera.x = -3500; // Apply camera to game objects game.x = gameCamera.x; } function completeLevel() { // Calculate completion bonus var completionBonus = 500; var treasureBonus = treasuresCollected * 50; var totalBonus = completionBonus + treasureBonus; LK.setScore(LK.getScore() + totalBonus); // Update storage if (currentLevel >= maxLevel) { maxLevel = currentLevel + 1; storage.maxLevel = maxLevel; } // Show completion message var completionText = new Text2('Level Complete!\nBonus: ' + totalBonus, { size: 100, fill: 0x00FF00 }); completionText.anchor.set(0.5, 0.5); LK.gui.center.addChild(completionText); // Flash screen green LK.effects.flashScreen(0x00ff00, 1000); // Advance to next level after delay LK.setTimeout(function () { completionText.destroy(); if (currentLevel < 5) { currentLevel++; storage.currentLevel = currentLevel; createLevel(currentLevel); } else { // Game completed LK.showYouWin(); } }, 2000); } // Touch controls game.down = function (x, y, obj) { // Use the x parameter directly as it's already in the correct coordinate space if (x < 1024) { keys.left = true; } else { keys.right = true; } // Jump on any touch keys.jump = true; }; game.up = function (x, y, obj) { keys.left = false; keys.right = false; keys.jump = false; }; // Initialize game initializeUI(); createLevel(currentLevel); LK.playMusic('bgmusic'); // Main game loop game.update = function () { if (levelCompleted) return; // Handle input if (keys.left) { player.moveLeft(); } if (keys.right) { player.moveRight(); } if (keys.jump) { player.jump(); keys.jump = false; // Prevent continuous jumping } // Update all game objects player.update(); for (var i = 0; i < treasures.length; i++) { treasures[i].update(); } for (var i = 0; i < enemies.length; i++) { enemies[i].update(); } for (var i = 0; i < powerUps.length; i++) { powerUps[i].update(); } // Check collisions checkCollisions(); // Update camera updateCamera(); // Check win condition (optional: complete level with all treasures) if (treasuresCollected >= totalTreasures && goal && goal.reached) { // Extra bonus for collecting all treasures LK.setScore(LK.getScore() + 200); updateUI(); } };
===================================================================
--- original.js
+++ change.js
@@ -1364,10 +1364,10 @@
}, 2000);
}
// Touch controls
game.down = function (x, y, obj) {
- var localPos = game.toLocal(obj.parent.toGlobal(obj.position));
- if (localPos.x < 1024) {
+ // Use the x parameter directly as it's already in the correct coordinate space
+ if (x < 1024) {
keys.left = true;
} else {
keys.right = true;
}
but like nathan drake. In-Game asset. 2d. High contrast. No shadows
silahlı çöl kıyafeti giyen bir asker. In-Game asset. 2d. High contrast. No shadows
Not a chest, just one valuable item such as a gold earring, a silver historical container or similar, but only one. In-Game asset. 2d. High contrast. No shadows
sand like a flat road. In-Game asset. 2d. High contrast. No shadows
a wall built with flat, mossy stones. In-Game asset. 2d. High contrast. No shadows
rusted iron door. In-Game asset. 2d. High contrast. No shadows