User prompt
Bombayı aldıktan sonra yanımdaki canavarlar patlasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yerde özel güçler atsın şansa göre 50 ihtmal gibi mesala bomba
User prompt
Kılıçları da birazcık daha büyük yapar mısın
User prompt
Kılıçlar da birazcık daha büyük yapar mısın
User prompt
Playeri birazcık daha büyük yapar mısın
User prompt
Kılıçlar playerin eline tam otursun
User prompt
Statü arka planı güzel bir görsel eklemek istiyorum
User prompt
Playeri birazcık daha büyük yapar mısın
User prompt
Keşke biraz insan hareket etse yürütürken sağ sol bakacak
User prompt
Player büyük yapar mısın biraz
User prompt
Tam. Ekrana olarak otursun
User prompt
hareket ettirmek için hareket oku ekler misiniz
User prompt
Hareket etmiyor player
User prompt
Hareket etmiyor
User prompt
Player insan gibi hareket ettirmek istiyorum yapar mısın
User prompt
Coinle bir şeyler alalım menüye shop ekler misiniz
User prompt
Coini şansa göre atsın
User prompt
Coin ekler misin
User prompt
Statünün arka planını kaldır
User prompt
Statüyü başka menü ekleyebilir misiniz
User prompt
Statü artması güç hız can basma gibi ekler misiniz
User prompt
Bossu farklı bir yaratık yapacam
User prompt
Her 10 level de boss gelsin istiyorum
User prompt
Daha düzgün hareket ettirmek istiyorum
User prompt
Satü ekler misiniz
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Boss monster class var Boss = Container.expand(function () { var self = Container.call(this); // Boss uses a unique look: purple color, ellipse shape, and is much larger var bossGraphics = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 5.0, scaleY: 4.0 }); self.hp = 300; self.maxHp = 300; self.speed = 0.8; self.xpValue = 250; self.level = player ? player.level : 10; // Boss level matches player level or 10 if not defined // Health bar properties and initialization self.maxHealthBarWidth = bossGraphics.width * 0.9; self.healthBarHeight = 18; var healthBarGap = 10; self.healthBarOffsetY = -(bossGraphics.height / 2) - self.healthBarHeight / 2 - healthBarGap; self.healthBarBackground = self.attachAsset('monster_hp_bg', { shape: 'box', width: self.maxHealthBarWidth, height: self.healthBarHeight, color: 0x550000, anchorX: 0.5, anchorY: 0.5, x: 0, y: self.healthBarOffsetY }); self.healthBarCurrent = self.attachAsset('monster_hp_fg', { shape: 'box', width: self.maxHealthBarWidth, height: self.healthBarHeight, color: 0xFFD700, anchorX: 0, anchorY: 0.5, x: -self.maxHealthBarWidth / 2, y: self.healthBarOffsetY }); self.levelText = new Text2('BOSS Lv.' + self.level, { size: 32, fill: 0xFFD700 }); self.levelText.anchor.set(0.5, 0.5); self.levelText.x = 0; self.levelText.y = self.healthBarOffsetY - 30; self.addChild(self.levelText); self.updateHealthBar = function () { var healthPercentage = Math.max(0, self.hp / self.maxHp); self.healthBarCurrent.width = self.maxHealthBarWidth * healthPercentage; }; self.takeDamage = function (damage) { self.hp -= damage; LK.effects.flashObject(self, 0xFF00FF, 200); self.updateHealthBar(); if (self.hp <= 0) { self.die(); } }; self.die = function () { var xpOrb = new XPOrb(); xpOrb.x = self.x; xpOrb.y = self.y; xpOrb.xpValue = self.xpValue; game.addChild(xpOrb); xpOrbs.push(xpOrb); // Spawn coins based on a random chance when the boss dies for (var i = 0; i < 10; i++) { // Increased potential coin drops if (Math.random() < 0.7) { // 70% chance to spawn a coin var coin = new Coin(); coin.x = self.x + Math.random() * 80 - 40; // Spawn coins around the boss coin.y = self.y + Math.random() * 80 - 40; game.addChild(coin); coinsArray.push(coin); } } var index = monsters.indexOf(self); if (index > -1) { monsters.splice(index, 1); } self.destroy(); }; self.update = function () { var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } if (distance < 100) { player.hp -= 1.2; // Boss deals more damage if (player.hp <= 0) { LK.showGameOver(); } } }; self.updateHealthBar(); return self; }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.magnetSpeed = 5; // Speed at which coins move towards player self.update = function () { if (self.collected) return; var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 100) { // Magnet range for coins self.x += dx / distance * self.magnetSpeed; self.y += dy / distance * self.magnetSpeed; if (distance < 40) { // Collection distance self.collect(); } } }; self.collect = function () { if (self.collected) return; self.collected = true; coins++; // Increment coin count if (typeof coinText !== "undefined") coinText.setText('Coins: ' + coins); var index = coinsArray.indexOf(self); if (index > -1) { coinsArray.splice(index, 1); } self.destroy(); }; return self; }); var Monster = Container.expand(function () { var self = Container.call(this); // Define methods on self self.updateHealthBar = function () { var healthPercentage = Math.max(0, self.hp / self.maxHp); // Ensure non-negative percentage self.healthBarCurrent.width = self.maxHealthBarWidth * healthPercentage; }; self.takeDamage = function (damage) { self.hp -= damage; LK.effects.flashObject(self, 0xFF0000, 200); self.updateHealthBar(); // Update health bar display if (self.hp <= 0) { self.die(); } }; self.die = function () { var xpOrb = new XPOrb(); xpOrb.x = self.x; xpOrb.y = self.y; xpOrb.xpValue = self.xpValue; game.addChild(xpOrb); xpOrbs.push(xpOrb); // Spawn a coin with a 50% chance when a monster dies if (Math.random() < 0.5) { var coin = new Coin(); coin.x = self.x + Math.random() * 40 - 20; // Spawn coin slightly offset coin.y = self.y + Math.random() * 40 - 20; // Spawn coin slightly offset game.addChild(coin); coinsArray.push(coin); } var index = monsters.indexOf(self); if (index > -1) { monsters.splice(index, 1); } self.destroy(); // This will also destroy child health bars }; self.update = function () { var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } if (distance < 50) { player.hp -= 0.2; // Player takes less damage if (player.hp <= 0) { LK.showGameOver(); } } }; // Constructor logic var monsterGraphics = self.attachAsset('monster', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, // Increased from 1.5 scaleY: 2.0 // Increased from 1.5 }); self.hp = 30; self.maxHp = 30; self.speed = 1; self.xpValue = 25; self.level = Math.floor(Math.random() * 5) + 1; // Random level between 1-5 // Health bar properties and initialization self.maxHealthBarWidth = monsterGraphics.width * 0.8; // Health bar width relative to monster width self.healthBarHeight = 8; var healthBarGap = 5; // Gap between monster and health bar // Position health bar above the monster graphics self.healthBarOffsetY = -(monsterGraphics.height / 2) - self.healthBarHeight / 2 - healthBarGap; self.healthBarBackground = self.attachAsset('monster_hp_bg', { shape: 'box', width: self.maxHealthBarWidth, height: self.healthBarHeight, color: 0x550000, // Dark red for background anchorX: 0.5, // Center the background bar horizontally anchorY: 0.5, // Center the background bar vertically x: 0, // Centered horizontally relative to the monster y: self.healthBarOffsetY // Positioned above the monster }); self.healthBarCurrent = self.attachAsset('monster_hp_fg', { shape: 'box', width: self.maxHealthBarWidth, // Initial full width height: self.healthBarHeight, color: 0x00FF00, // Green for current health anchorX: 0, // Align left edge of the current health bar anchorY: 0.5, // Center the current health bar vertically // Position its left edge to align with the left edge of the background bar x: -self.maxHealthBarWidth / 2, y: self.healthBarOffsetY // Positioned above the monster }); // Monster level text self.levelText = new Text2('Lv.' + self.level, { size: 16, fill: 0xFFFFFF }); self.levelText.anchor.set(0.5, 0.5); self.levelText.x = 0; self.levelText.y = self.healthBarOffsetY - 20; // Position above health bar self.addChild(self.levelText); self.updateHealthBar(); // Initial call to set health bar width correctly return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2 }); self.level = 1; self.xp = 0; self.xpToNext = 100; self.hp = 100; self.maxHp = 100; self.damage = 10; self.attackCooldown = 0; self.sword = null; self.vx = 0; // Horizontal velocity self.vy = 0; // Vertical velocity self.createSword = function () { if (self.sword) { self.removeChild(self.sword); } var swordType = 'woodenSword'; var baseDamage = 10; // Calculate damage increase every 5 levels var damageMultiplier = Math.floor(self.level / 5); var damage = baseDamage + damageMultiplier * 5; if (self.level >= 20) { swordType = 'steelSword'; } else if (self.level >= 10) { swordType = 'ironSword'; } self.damage = damage; self.sword = self.attachAsset(swordType, { anchorX: 0, anchorY: 0.5, x: 45, y: 0 }); }; self.gainXP = function (amount) { self.xp += amount; if (self.xp >= self.xpToNext) { self.levelUp(); } }; self.levelUp = function () { self.level++; self.xp = 0; self.xpToNext = self.level * 100; // self.maxHp remains at 100, as per the "health up to 100" requirement. self.hp = self.maxHp; // Restore HP to the current maxHp (which is 100). statPoints += 1; // Give 1 stat point per level up if (typeof statPointText !== "undefined") statPointText.setText('Statü Puanı: ' + statPoints); if (self.level % 10 === 0) { self.createSword(); } LK.getSound('levelUp').play(); LK.effects.flashObject(self, 0xFFD700, 500); }; self.attack = function () { if (self.attackCooldown <= 0) { self.attackCooldown = 30; LK.getSound('attack').play(); if (self.sword) { tween(self.sword, { rotation: Math.PI / 4 }, { duration: 150, easing: tween.easeOut }); tween(self.sword, { rotation: 0 }, { duration: 150, easing: tween.easeIn }); } for (var i = monsters.length - 1; i >= 0; i--) { // Iterate backwards var monster = monsters[i]; var distance = Math.sqrt((self.x - monster.x) * (self.x - monster.x) + (self.y - monster.y) * (self.y - monster.y)); if (distance < 120) { // Increased attack range from 100 to 120 monster.takeDamage(self.damage); } } } }; self.update = function () { if (self.attackCooldown > 0) { self.attackCooldown--; } // Auto attack - attack every 30 frames (0.5 seconds) if (self.attackCooldown <= 0) { // Check if there are monsters nearby to attack var foundNearbyMonster = false; for (var i = 0; i < monsters.length; i++) { var monster = monsters[i]; var distance = Math.sqrt((self.x - monster.x) * (self.x - monster.x) + (self.y - monster.y) * (self.y - monster.y)); if (distance < 120) { foundNearbyMonster = true; break; } } if (foundNearbyMonster) { self.attack(); } } }; self.createSword(); return self; }); var XPOrb = Container.expand(function () { var self = Container.call(this); var orbGraphics = self.attachAsset('xpOrb', { anchorX: 0.5, anchorY: 0.5 }); self.xpValue = 25; self.magnetSpeed = 3; self.collected = false; self.update = function () { if (self.collected) return; var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 80) { self.x += dx / distance * self.magnetSpeed; self.y += dy / distance * self.magnetSpeed; if (distance < 30) { self.collect(); } } }; self.collect = function () { if (self.collected) return; self.collected = true; player.gainXP(self.xpValue); LK.getSound('xpPickup').play(); var index = xpOrbs.indexOf(self); if (index > -1) { xpOrbs.splice(index, 1); } self.destroy(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2F4F2F }); /**** * Game Code ****/ // Add the dungeon background first so it's behind all other game elements var dungeonBackgroundDisplay = game.addChild(LK.getAsset('dungeonBackground', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 // The asset is defined with width 2048 and height 2732, // so it will automatically cover the full game screen. })); var player; var monsters = []; var xpOrbs = []; var coinsArray = []; // Array to hold Coin instances var coins = 0; // Variable to keep track of coins collected var moveDirection = { x: 0, y: 0 }; var spawnTimer = 0; var activeGuiMenu = null; // To manage which GUI menu is currently open // Player movement physics constants var playerAcceleration = 0.5; // How quickly the player speeds up var playerMaxSpeed = 6; // Maximum speed of the player (same as previous constant speed) var playerFriction = 0.9; // How quickly the player slows down (0-1, lower is stronger friction) player = game.addChild(new Player()); player.x = 1024; player.y = 1366; player.targetX = player.x; player.targetY = player.y; player.isMovingToTarget = false; var levelText = new Text2('Level: 1', { size: 40, fill: 0xFFFFFF }); levelText.anchor.set(0, 0); LK.gui.topLeft.addChild(levelText); levelText.x = 120; levelText.y = 20; var xpText = new Text2('XP: 0/100', { size: 30, fill: 0xFFD700 }); xpText.anchor.set(0, 0); LK.gui.topLeft.addChild(xpText); xpText.x = 120; xpText.y = 70; var hpText = new Text2('HP: 100/100', { size: 30, fill: 0xFF4500 }); hpText.anchor.set(0, 0); LK.gui.topLeft.addChild(hpText); hpText.x = 120; hpText.y = 110; var coinText = new Text2('Coins: 0', { size: 30, fill: 0xFFFF00 }); coinText.anchor.set(0, 0); LK.gui.topLeft.addChild(coinText); coinText.x = 120; coinText.y = 150; // Position below HP text // Statü Menu Container var statusMenu = new Container(); LK.gui.center.addChild(statusMenu); statusMenu.visible = false; // Start hidden // Statü Menu Title var statusMenuTitle = new Text2('Statü Menüsü', { size: 48, fill: 0xFFD700 }); statusMenuTitle.anchor.set(0.5, 0); statusMenuTitle.x = 0; statusMenuTitle.y = -260; statusMenu.addChild(statusMenuTitle); // Statü Text (moved to menu) var statusText = new Text2('Statü: ' + player.damage, { size: 36, fill: 0xFFFFFF }); statusText.anchor.set(0.5, 0); statusText.x = 0; statusText.y = -180; statusMenu.addChild(statusText); // Stat Variables var statPoints = 0; var statGuc = 0; var statHiz = 0; var statCan = 0; // Stat buttons (moved to menu) var gucButton = new Text2('Güç +', { size: 36, fill: 0xFF0000 }); gucButton.anchor.set(0.5, 0); gucButton.x = -200; gucButton.y = -80; statusMenu.addChild(gucButton); var hizButton = new Text2('Hız +', { size: 36, fill: 0x00BFFF }); hizButton.anchor.set(0.5, 0); hizButton.x = 0; hizButton.y = -80; statusMenu.addChild(hizButton); var canButton = new Text2('Can +', { size: 36, fill: 0x32CD32 }); canButton.anchor.set(0.5, 0); canButton.x = 200; canButton.y = -80; statusMenu.addChild(canButton); var statPointText = new Text2('Statü Puanı: 0', { size: 32, fill: 0xFFD700 }); statPointText.anchor.set(0.5, 0); statPointText.x = 0; statPointText.y = 0; statusMenu.addChild(statPointText); // Statü Menu Close Button var closeStatusMenuButton = new Text2('Kapat', { size: 36, fill: 0xFFFFFF }); closeStatusMenuButton.anchor.set(0.5, 0); closeStatusMenuButton.x = 0; closeStatusMenuButton.y = 200; statusMenu.addChild(closeStatusMenuButton); closeStatusMenuButton.down = function () { statusMenu.visible = false; if (activeGuiMenu === statusMenu) activeGuiMenu = null; }; // Statü Menu Open Button (always visible, top right) var openStatusMenuButton = new Text2('Statü', { size: 36, fill: 0xFFD700 }); openStatusMenuButton.anchor.set(1, 0); LK.gui.topRight.addChild(openStatusMenuButton); openStatusMenuButton.x = -40; openStatusMenuButton.y = 40; openStatusMenuButton.down = function () { if (activeGuiMenu === statusMenu) { statusMenu.visible = false; activeGuiMenu = null; } else { if (activeGuiMenu) activeGuiMenu.visible = false; statusMenu.visible = true; activeGuiMenu = statusMenu; } }; // Move stat button event handlers to new context gucButton.down = function (x, y, obj) { if (statPoints > 0) { statGuc++; statPoints--; player.damage += 2; statPointText.setText('Statü Puanı: ' + statPoints); } }; hizButton.down = function (x, y, obj) { if (statPoints > 0) { statHiz++; statPoints--; playerMaxSpeed += 1.2; statPointText.setText('Statü Puanı: ' + statPoints); } }; canButton.down = function (x, y, obj) { if (statPoints > 0) { statCan++; statPoints--; player.hp += 20; if (player.hp > player.maxHp) player.hp = player.maxHp; statPointText.setText('Statü Puanı: ' + statPoints); } }; // Stat button event handlers gucButton.down = function (x, y, obj) { if (statPoints > 0) { statGuc++; statPoints--; player.damage += 2; statPointText.setText('Statü Puanı: ' + statPoints); } }; hizButton.down = function (x, y, obj) { if (statPoints > 0) { statHiz++; statPoints--; playerMaxSpeed += 1.2; statPointText.setText('Statü Puanı: ' + statPoints); } }; canButton.down = function (x, y, obj) { if (statPoints > 0) { statCan++; statPoints--; player.hp += 20; if (player.hp > player.maxHp) player.hp = player.maxHp; statPointText.setText('Statü Puanı: ' + statPoints); } }; // Shop Menu Elements var shopMenu = new Container(); LK.gui.center.addChild(shopMenu); shopMenu.visible = false; // Start hidden var shopMenuTitle = new Text2('Dükkan', { size: 48, fill: 0xFFD700 }); shopMenuTitle.anchor.set(0.5, 0); shopMenuTitle.x = 0; shopMenuTitle.y = -260; // Position above center shopMenu.addChild(shopMenuTitle); // Shop Item 1: Health Potion var buyHealthPotionButton = new Text2('Can İksiri Al (10 Coin)', { size: 36, fill: 0x32CD32 // Green color for health }); buyHealthPotionButton.anchor.set(0.5, 0); buyHealthPotionButton.x = 0; buyHealthPotionButton.y = -180; // Below title shopMenu.addChild(buyHealthPotionButton); buyHealthPotionButton.down = function () { if (coins >= 10) { coins -= 10; player.hp += 25; if (player.hp > player.maxHp) player.hp = player.maxHp; if (typeof coinText !== "undefined") coinText.setText('Coins: ' + coins); // Update HP and Status text as HP changes if (typeof hpText !== "undefined") hpText.setText('HP: ' + Math.max(0, Math.floor(player.hp)) + '/' + player.maxHp); if (typeof statusText !== "undefined") statusText.setText('Statü: ' + player.damage + ' | Hız: ' + Math.round(playerMaxSpeed * 10) / 10 + ' | Can: ' + Math.floor(player.hp)); } else { LK.effects.flashObject(buyHealthPotionButton, 0xFF0000, 300); // Flash red if not enough coins } }; // Shop Item 2: Damage Boost var buyDamageBoostButton = new Text2('Hasar Artışı Al (20 Coin)', { size: 36, fill: 0xFF0000 // Red color for damage }); buyDamageBoostButton.anchor.set(0.5, 0); buyDamageBoostButton.x = 0; buyDamageBoostButton.y = -100; // Below health potion button shopMenu.addChild(buyDamageBoostButton); buyDamageBoostButton.down = function () { if (coins >= 20) { coins -= 20; player.damage += 5; // Permanent damage increase if (typeof coinText !== "undefined") coinText.setText('Coins: ' + coins); // Update Status text as damage changes if (typeof statusText !== "undefined") statusText.setText('Statü: ' + player.damage + ' | Hız: ' + Math.round(playerMaxSpeed * 10) / 10 + ' | Can: ' + Math.floor(player.hp)); } else { LK.effects.flashObject(buyDamageBoostButton, 0xFF0000, 300); // Flash red } }; // Shop Menu Close Button var closeShopMenuButton = new Text2('Kapat', { size: 36, fill: 0xFFFFFF }); closeShopMenuButton.anchor.set(0.5, 0); closeShopMenuButton.x = 0; closeShopMenuButton.y = 200; // Position below center shopMenu.addChild(closeShopMenuButton); closeShopMenuButton.down = function () { shopMenu.visible = false; if (activeGuiMenu === shopMenu) activeGuiMenu = null; }; // Shop Menu Open Button (always visible, top right) var openShopMenuButton = new Text2('Dükkan', { size: 36, fill: 0xFFD700 }); openShopMenuButton.anchor.set(1, 0); // Anchor to top-right for positioning LK.gui.topRight.addChild(openShopMenuButton); openShopMenuButton.x = -40; // Align with Statü button openShopMenuButton.y = 100; // Position below the Statü button (Statü is at y=40) openShopMenuButton.down = function () { if (activeGuiMenu === shopMenu) { shopMenu.visible = false; activeGuiMenu = null; } else { if (activeGuiMenu) activeGuiMenu.visible = false; // Close any other active menu shopMenu.visible = true; activeGuiMenu = shopMenu; } }; // Touch/drag movement: start drag if touch is on player, else ignore var draggingPlayer = false; game.down = function (x, y, obj) { // Check if touch is on player (within player sprite bounds) var dx = x - player.x; var dy = y - player.y; var playerRadius = 90; // Approximate touch radius for player (player asset is 150x168) if (dx * dx + dy * dy < playerRadius * playerRadius) { draggingPlayer = true; player.isMovingToTarget = false; moveDirection.x = 0; moveDirection.y = 0; player.dragOffsetX = player.x - x; player.dragOffsetY = player.y - y; } }; game.move = function (x, y, obj) { if (draggingPlayer) { // Move player to follow finger, but clamp to boundaries var newX = x + player.dragOffsetX; var newY = y + player.dragOffsetY; // Clamp to boundaries if (newX < 40) newX = 40; if (newX > 2008) newX = 2008; if (newY < 40) newY = 40; if (newY > 2692) newY = 2692; player.x = newX; player.y = newY; // Stop velocity so player doesn't keep moving after drag player.vx = 0; player.vy = 0; } }; game.up = function (x, y, obj) { draggingPlayer = false; player.isMovingToTarget = false; moveDirection.x = 0; moveDirection.y = 0; }; function spawnMonster() { var monster = new Monster(); var side = Math.floor(Math.random() * 4); if (side === 0) { monster.x = Math.random() * 2048; monster.y = -50; } else if (side === 1) { monster.x = 2098; monster.y = Math.random() * 2732; } else if (side === 2) { monster.x = Math.random() * 2048; monster.y = 2782; } else { monster.x = -50; monster.y = Math.random() * 2732; } game.addChild(monster); monsters.push(monster); } game.update = function () { // Boss spawn logic if (!game.bossActive && player.level > 0 && player.level % 10 === 0) { // Only spawn boss if not already present and at a boss level var bossExists = false; for (var i = 0; i < monsters.length; i++) { if (monsters[i] && monsters[i].levelText && monsters[i].levelText.text && monsters[i].levelText.text.indexOf('BOSS') !== -1) { bossExists = true; break; } } if (!bossExists) { var boss = new Boss(); // Spawn boss in the center of the map boss.x = 1024; boss.y = 600; game.addChild(boss); monsters.push(boss); game.bossActive = true; } } // Only spawn normal monsters if not in boss fight if (!game.bossActive) { spawnTimer++; if (spawnTimer >= 120) { spawnMonster(); spawnTimer = 0; } } else { // If boss is dead, clear bossActive flag var bossStillAlive = false; for (var i = 0; i < monsters.length; i++) { if (monsters[i] && monsters[i].levelText && monsters[i].levelText.text && monsters[i].levelText.text.indexOf('BOSS') !== -1) { bossStillAlive = true; break; } } if (!bossStillAlive) { game.bossActive = false; } } // If not dragging, apply friction to velocity for idle movement if (!draggingPlayer) { player.vx *= playerFriction; if (Math.abs(player.vx) < 0.1) player.vx = 0; player.vy *= playerFriction; if (Math.abs(player.vy) < 0.1) player.vy = 0; } // Calculate new potential position var newX = player.x + player.vx; var newY = player.y + player.vy; // Boundary checks and position update for X // The boundaries (40, 2008, etc.) are assumed to be for the player's center (x,y) if (newX >= 40 && newX <= 2008) { player.x = newX; } else { player.vx = 0; // Stop horizontal movement if hitting a boundary // Snap player to the boundary edge if (newX < 40) player.x = 40;else if (newX > 2008) player.x = 2008; } // Boundary checks and position update for Y if (newY >= 40 && newY <= 2692) { player.y = newY; } else { player.vy = 0; // Stop vertical movement if hitting a boundary // Snap player to the boundary edge if (newY < 40) player.y = 40;else if (newY > 2692) player.y = 2692; } for (var i = monsters.length - 1; i >= 0; i--) { var monster = monsters[i]; if (monster.x < -100 || monster.x > 2148 || monster.y < -100 || monster.y > 2832) { monster.destroy(); monsters.splice(i, 1); } } for (var j = xpOrbs.length - 1; j >= 0; j--) { var orb = xpOrbs[j]; if (orb.x < -50 || orb.x > 2098 || orb.y < -50 || orb.y > 2782) { orb.destroy(); xpOrbs.splice(j, 1); } } for (var k = coinsArray.length - 1; k >= 0; k--) { var coin = coinsArray[k]; if (coin.x < -50 || coin.x > 2098 || coin.y < -50 || coin.y > 2782) { coin.destroy(); coinsArray.splice(k, 1); } } levelText.setText('Level: ' + player.level); xpText.setText('XP: ' + player.xp + '/' + player.xpToNext); hpText.setText('HP: ' + Math.max(0, Math.floor(player.hp)) + '/' + player.maxHp); coinText.setText('Coins: ' + coins); // Update coin text statusText.setText('Statü: ' + player.damage + ' | Hız: ' + Math.round(playerMaxSpeed * 10) / 10 + ' | Can: ' + Math.floor(player.hp)); statPointText.setText('Statü Puanı: ' + statPoints); };
===================================================================
--- original.js
+++ change.js
@@ -707,26 +707,46 @@
shopMenu.visible = true;
activeGuiMenu = shopMenu;
}
};
+// Touch/drag movement: start drag if touch is on player, else ignore
+var draggingPlayer = false;
game.down = function (x, y, obj) {
- // Set the target position for the player to move towards
- player.targetX = x;
- player.targetY = y;
- player.isMovingToTarget = true;
- // Optionally, you can still set moveDirection for fallback
+ // Check if touch is on player (within player sprite bounds)
var dx = x - player.x;
var dy = y - player.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance > 0) {
- moveDirection.x = dx / distance;
- moveDirection.y = dy / distance;
+ var playerRadius = 90; // Approximate touch radius for player (player asset is 150x168)
+ if (dx * dx + dy * dy < playerRadius * playerRadius) {
+ draggingPlayer = true;
+ player.isMovingToTarget = false;
+ moveDirection.x = 0;
+ moveDirection.y = 0;
+ player.dragOffsetX = player.x - x;
+ player.dragOffsetY = player.y - y;
}
};
+game.move = function (x, y, obj) {
+ if (draggingPlayer) {
+ // Move player to follow finger, but clamp to boundaries
+ var newX = x + player.dragOffsetX;
+ var newY = y + player.dragOffsetY;
+ // Clamp to boundaries
+ if (newX < 40) newX = 40;
+ if (newX > 2008) newX = 2008;
+ if (newY < 40) newY = 40;
+ if (newY > 2692) newY = 2692;
+ player.x = newX;
+ player.y = newY;
+ // Stop velocity so player doesn't keep moving after drag
+ player.vx = 0;
+ player.vy = 0;
+ }
+};
game.up = function (x, y, obj) {
+ draggingPlayer = false;
+ player.isMovingToTarget = false;
moveDirection.x = 0;
moveDirection.y = 0;
- player.isMovingToTarget = false;
};
function spawnMonster() {
var monster = new Monster();
var side = Math.floor(Math.random() * 4);
@@ -786,26 +806,10 @@
if (!bossStillAlive) {
game.bossActive = false;
}
}
- // Smooth movement towards target using tweening
- if (player.isMovingToTarget && typeof player.targetX === "number" && typeof player.targetY === "number") {
- var dx = player.targetX - player.x;
- var dy = player.targetY - player.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance > 5) {
- // Move a fraction of the distance each frame for smoothness
- var moveSpeed = playerMaxSpeed;
- player.vx = dx / distance * moveSpeed;
- player.vy = dy / distance * moveSpeed;
- } else {
- // Close enough to target, stop moving
- player.vx = 0;
- player.vy = 0;
- player.isMovingToTarget = false;
- }
- } else {
- // Player not moving to a target, use friction to slow down
+ // If not dragging, apply friction to velocity for idle movement
+ if (!draggingPlayer) {
player.vx *= playerFriction;
if (Math.abs(player.vx) < 0.1) player.vx = 0;
player.vy *= playerFriction;
if (Math.abs(player.vy) < 0.1) player.vy = 0;
ironSword. In-Game asset. High contrast. No shadows
Aynısını istiyorum farklı renklerle
Ayakları olsun istiyorum ve düz dursun istiyorum Arka plan yok
Arka plan yok olmalı Beyaz olsun
Bomba. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Coin. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat