User prompt
kontorolleri öncekine geri alalım
User prompt
sadece sürükleme kontrolüne geçelim
User prompt
magaza butonuna tiklandiginda oyun dursun butun ekrani kaplamayan ortada acilan bir serit pencere olsun
User prompt
magaza butonunu sol alt koseye kenardan 1x1 cm uzakliga alalim ve buton tiklanabilir olsun
User prompt
mermi rengini mavi yapalim, magaza da kirmizi, turuncu, mavi, sari, mor renkler olsun bu renkler satin alinabilir olsun 10 saniyede bir on hizi 2 kat arttsin
User prompt
oyuna magaza ozelligi para getirelim para sari renk olsun magaza da dis gorunusler olsun kademeli satin alimlar gibi cok abartili fiyatlar olmasin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
hareket etmediginde oyun durma ozelligini kaldiralim
User prompt
10 saniye de bir oyun seviyesi arttsin yani daha dusmanlar daha hizli hareket etsin
Code edit (1 edits merged)
Please save this source code
User prompt
Motion Control Game
User prompt
oyunda karakter hareket etmedigi surece oyun aki dursun hareket ettigi surece oyun devam etsin
Initial prompt
ben bir parkur oyunu yapmak istiyorum
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { coins: 0, unlockedSkins: ["default"] }); /**** * Classes ****/ var Bullet = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.baseSpeedX = (Math.random() - 0.5) * 6; self.baseSpeedY = Math.random() * 4 + 2; self.update = function () { // Apply difficulty multiplier to speed - double every level var speedMultiplier = Math.pow(2, difficultyLevel - 1); self.x += self.baseSpeedX * speedMultiplier; self.y += self.baseSpeedY * speedMultiplier; }; return self; }); var Coin = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.bobSpeed = Math.random() * 0.15 + 0.08; self.bobOffset = Math.random() * Math.PI * 2; self.update = function () { // Gentle bobbing animation and rotation graphics.y = Math.sin(LK.ticks * self.bobSpeed + self.bobOffset) * 8; graphics.rotation += 0.05; graphics.scaleX = 1 + Math.sin(LK.ticks * 0.1) * 0.1; graphics.scaleY = 1 + Math.sin(LK.ticks * 0.1) * 0.1; }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.baseSpeedX = (Math.random() - 0.5) * 4; self.baseSpeedY = Math.random() * 3 + 1; self.update = function () { // Apply difficulty multiplier to speed - double every level var speedMultiplier = Math.pow(2, difficultyLevel - 1); self.x += self.baseSpeedX * speedMultiplier; self.y += self.baseSpeedY * speedMultiplier; // Bounce off screen edges if (self.x <= 30 || self.x >= 2018) { self.baseSpeedX *= -1; } }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Keep player at normal appearance graphics.alpha = 1.0; graphics.scaleX = 1.0; graphics.scaleY = 1.0; }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('powerup', { anchorX: 0.5, anchorY: 0.5 }); self.bobSpeed = Math.random() * 0.1 + 0.05; self.bobOffset = Math.random() * Math.PI * 2; self.update = function () { // Gentle bobbing animation graphics.y = Math.sin(LK.ticks * self.bobSpeed + self.bobOffset) * 5; graphics.rotation += 0.02; }; return self; }); var Shop = Container.expand(function () { var self = Container.call(this); // Shop background var background = LK.getAsset('shop', { width: 1800, height: 2200, color: 0x2C3E50, shape: 'box' }); background.anchorX = 0.5; background.anchorY = 0.5; background.alpha = 0.95; self.addChild(background); // Shop title var title = new Text2('SHOP', { size: 100, fill: 0xFFD700 }); title.anchor.set(0.5, 0.5); title.x = 0; title.y = -900; self.addChild(title); // Coins display self.coinsText = new Text2('Coins: ' + storage.coins, { size: 60, fill: 0xFFD700 }); self.coinsText.anchor.set(0.5, 0.5); self.coinsText.x = 0; self.coinsText.y = -800; self.addChild(self.coinsText); // Close button var closeBtn = LK.getAsset('closeBtn', { width: 120, height: 120, color: 0xE74C3C, shape: 'box' }); closeBtn.anchorX = 0.5; closeBtn.anchorY = 0.5; closeBtn.x = 800; closeBtn.y = -900; self.addChild(closeBtn); var closeText = new Text2('X', { size: 80, fill: 0xFFFFFF }); closeText.anchor.set(0.5, 0.5); closeText.x = 800; closeText.y = -900; self.addChild(closeText); // Skin items self.skins = [{ name: 'default', color: 0x4caf50, price: 0, unlocked: true }, { name: 'red', color: 0xF44336, price: 50, unlocked: storage.unlockedSkins.indexOf('red') !== -1 }, { name: 'orange', color: 0xFF9800, price: 100, unlocked: storage.unlockedSkins.indexOf('orange') !== -1 }, { name: 'blue', color: 0x2196F3, price: 150, unlocked: storage.unlockedSkins.indexOf('blue') !== -1 }, { name: 'yellow', color: 0xFFEB3B, price: 200, unlocked: storage.unlockedSkins.indexOf('yellow') !== -1 }, { name: 'purple', color: 0x9C27B0, price: 250, unlocked: storage.unlockedSkins.indexOf('purple') !== -1 }]; self.skinButtons = []; for (var i = 0; i < self.skins.length; i++) { var skin = self.skins[i]; var yPos = -500 + i * 200; // Skin preview var skinPreview = LK.getAsset('skinPreview' + i, { width: 80, height: 80, color: skin.color, shape: 'ellipse' }); skinPreview.anchorX = 0.5; skinPreview.anchorY = 0.5; skinPreview.x = -400; skinPreview.y = yPos; self.addChild(skinPreview); // Skin name var nameText = new Text2(skin.name.toUpperCase(), { size: 50, fill: 0xFFFFFF }); nameText.anchor.set(0, 0.5); nameText.x = -300; nameText.y = yPos - 30; self.addChild(nameText); // Price or status var statusText; if (skin.unlocked) { statusText = new Text2('OWNED', { size: 40, fill: 0x4CAF50 }); } else { statusText = new Text2(skin.price + ' coins', { size: 40, fill: 0xFFD700 }); } statusText.anchor.set(0, 0.5); statusText.x = -300; statusText.y = yPos + 30; self.addChild(statusText); // Buy/Use button var button = LK.getAsset('shopBtn' + i, { width: 200, height: 80, color: skin.unlocked ? 0x4CAF50 : 0x2196F3, shape: 'box' }); button.anchorX = 0.5; button.anchorY = 0.5; button.x = 400; button.y = yPos; button.skinIndex = i; self.addChild(button); self.skinButtons.push(button); var buttonText = new Text2(skin.unlocked ? 'USE' : 'BUY', { size: 40, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); buttonText.x = 400; buttonText.y = yPos; self.addChild(buttonText); } self.down = function (x, y, obj) { var localPos = self.toLocal(obj.parent.toGlobal(obj.position)); // Close button if (localPos.x > 740 && localPos.x < 860 && localPos.y > -960 && localPos.y < -840) { showShop = false; self.visible = false; return; } // Check skin buttons for (var i = 0; i < self.skinButtons.length; i++) { var button = self.skinButtons[i]; var skin = self.skins[i]; if (localPos.x > 300 && localPos.x < 500 && localPos.y > -500 + i * 200 - 40 && localPos.y < -500 + i * 200 + 40) { if (skin.unlocked) { // Use skin currentSkin = skin.name; storage.currentSkin = currentSkin; updatePlayerSkin(); } else { // Buy skin if (storage.coins >= skin.price) { storage.coins -= skin.price; storage.unlockedSkins.push(skin.name); skin.unlocked = true; currentSkin = skin.name; storage.currentSkin = currentSkin; updatePlayerSkin(); self.updateShop(); } } break; } } }; self.updateShop = function () { self.coinsText.setText('Coins: ' + storage.coins); for (var i = 0; i < self.skins.length; i++) { self.skins[i].unlocked = storage.unlockedSkins.indexOf(self.skins[i].name) !== -1; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1A1A2E }); /**** * Game Code ****/ var player; var enemies = []; var bullets = []; var powerups = []; var coins = []; var survivalTime = 0; var spawnTimer = 0; var difficultyLevel = 1; var dragNode = null; var levelTimer = 0; var baseEnemySpeed = 3; var baseBulletSpeed = 4; var showShop = false; var shop; var currentSkin = storage.currentSkin || 'default'; // Initialize score display var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Initialize level display var levelTxt = new Text2('Level: 1', { size: 60, fill: 0xFFD700 }); levelTxt.anchor.set(0.5, 0); levelTxt.x = 2048 / 2; levelTxt.y = 60; LK.gui.addChild(levelTxt); // Initialize coins display var coinsTxt = new Text2('Coins: ' + storage.coins, { size: 50, fill: 0xFFD700 }); coinsTxt.anchor.set(1, 0); coinsTxt.x = 2048 - 20; coinsTxt.y = 20; LK.gui.addChild(coinsTxt); // Initialize shop button var shopBtn = LK.getAsset('shopButton', { width: 150, height: 80, color: 0x9C27B0, shape: 'box' }); shopBtn.anchorX = 0; shopBtn.anchorY = 1; shopBtn.x = 38; // 1cm from left edge (approximately 38px) shopBtn.y = LK.gui.height - 38; // 1cm from bottom edge LK.gui.addChild(shopBtn); var shopBtnText = new Text2('SHOP', { size: 40, fill: 0xFFFFFF }); shopBtnText.anchor.set(0.5, 0.5); shopBtnText.x = 113; // Center of button (38 + 150/2) shopBtnText.y = LK.gui.height - 78; // Center of button vertically LK.gui.addChild(shopBtnText); // Create player player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 / 2; // Create shop shop = new Shop(); shop.x = 2048 / 2; shop.y = 2732 / 2; shop.visible = false; game.addChild(shop); // Function to update player skin function updatePlayerSkin() { var skinColors = { 'default': 0x4caf50, 'red': 0xF44336, 'orange': 0xFF9800, 'blue': 0x2196F3, 'yellow': 0xFFEB3B, 'purple': 0x9C27B0 }; if (player && player.children[0]) { player.children[0].tint = skinColors[currentSkin] || skinColors['default']; } } // Apply current skin updatePlayerSkin(); // Movement handling function handleMove(x, y, obj) { if (dragNode && !showShop) { dragNode.x = Math.max(40, Math.min(2008, x)); dragNode.y = Math.max(40, Math.min(2692, y)); } } game.move = handleMove; game.down = function (x, y, obj) { // Check shop button click (bottom left corner) if (x > 38 && x < 188 && y > LK.gui.height - 118 && y < LK.gui.height - 38) { showShop = !showShop; shop.visible = showShop; if (showShop) { shop.updateShop(); } return; } // Only allow player movement if shop is not open if (!showShop) { dragNode = player; handleMove(x, y, obj); } }; game.up = function (x, y, obj) { dragNode = null; }; // Spawn enemies function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * 1900 + 100; enemy.y = -50; enemies.push(enemy); game.addChild(enemy); } // Spawn bullets function spawnBullet() { var bullet = new Bullet(); bullet.x = Math.random() * 2048; bullet.y = -30; bullets.push(bullet); game.addChild(bullet); } // Spawn power-ups function spawnPowerUp() { var powerup = new PowerUp(); powerup.x = Math.random() * 1800 + 124; powerup.y = Math.random() * 2000 + 100; powerups.push(powerup); game.addChild(powerup); } // Spawn coins function spawnCoin() { var coin = new Coin(); coin.x = Math.random() * 1800 + 124; coin.y = Math.random() * 2000 + 100; coins.push(coin); game.addChild(coin); } // Update game state game.update = function () { // Update game progression survivalTime++; levelTimer++; spawnTimer++; // Update score LK.setScore(Math.floor(survivalTime / 60) * 10); scoreTxt.setText('Score: ' + LK.getScore()); // Increase difficulty every 10 seconds (600 ticks at 60fps) if (levelTimer >= 600) { difficultyLevel++; levelTimer = 0; levelTxt.setText('Level: ' + difficultyLevel); // Flash screen to indicate level up LK.effects.flashScreen(0x00FF00, 300); } // Spawn enemies if (spawnTimer % Math.max(120 - difficultyLevel * 10, 30) === 0) { spawnEnemy(); } // Spawn bullets if (spawnTimer % Math.max(90 - difficultyLevel * 5, 20) === 0) { spawnBullet(); } // Spawn power-ups if (spawnTimer % 600 === 0) { spawnPowerUp(); } // Spawn coins if (spawnTimer % 180 === 0) { spawnCoin(); } // Handle enemy collisions and cleanup for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; // Remove off-screen enemies if (enemy.y > 2800) { enemy.destroy(); enemies.splice(i, 1); continue; } // Check collision with player if (enemy.intersects(player)) { LK.getSound('enemyHit').play(); LK.effects.flashScreen(0xFF0000, 500); LK.showGameOver(); return; } } // Handle bullet collisions and cleanup for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; // Remove off-screen bullets if (bullet.y > 2800 || bullet.x < -50 || bullet.x > 2098) { bullet.destroy(); bullets.splice(i, 1); continue; } // Check collision with player if (bullet.intersects(player)) { LK.getSound('enemyHit').play(); LK.effects.flashScreen(0xFF0000, 500); LK.showGameOver(); return; } } // Handle power-up collisions for (var i = powerups.length - 1; i >= 0; i--) { var powerup = powerups[i]; if (powerup.intersects(player)) { LK.getSound('collect').play(); LK.setScore(LK.getScore() + 50); scoreTxt.setText('Score: ' + LK.getScore()); LK.effects.flashObject(player, 0x2196F3, 300); powerup.destroy(); powerups.splice(i, 1); } } // Handle coin collisions for (var i = coins.length - 1; i >= 0; i--) { var coin = coins[i]; if (coin.intersects(player)) { LK.getSound('collect').play(); storage.coins += 10; coinsTxt.setText('Coins: ' + storage.coins); LK.effects.flashObject(player, 0xFFD700, 300); coin.destroy(); coins.splice(i, 1); } } // Win condition if (LK.getScore() >= 1000) { LK.showYouWin(); } };
===================================================================
--- original.js
+++ change.js
@@ -340,19 +340,19 @@
color: 0x9C27B0,
shape: 'box'
});
shopBtn.anchorX = 0;
-shopBtn.anchorY = 0;
-shopBtn.x = 120;
-shopBtn.y = 20;
+shopBtn.anchorY = 1;
+shopBtn.x = 38; // 1cm from left edge (approximately 38px)
+shopBtn.y = LK.gui.height - 38; // 1cm from bottom edge
LK.gui.addChild(shopBtn);
var shopBtnText = new Text2('SHOP', {
size: 40,
fill: 0xFFFFFF
});
shopBtnText.anchor.set(0.5, 0.5);
-shopBtnText.x = 195;
-shopBtnText.y = 60;
+shopBtnText.x = 113; // Center of button (38 + 150/2)
+shopBtnText.y = LK.gui.height - 78; // Center of button vertically
LK.gui.addChild(shopBtnText);
// Create player
player = game.addChild(new Player());
player.x = 2048 / 2;
@@ -387,10 +387,10 @@
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
- // Check shop button click
- if (x > 120 && x < 270 && y > 20 && y < 100) {
+ // Check shop button click (bottom left corner)
+ if (x > 38 && x < 188 && y > LK.gui.height - 118 && y < LK.gui.height - 38) {
showShop = !showShop;
shop.visible = showShop;
if (showShop) {
shop.updateShop();