User prompt
100 levele kadar farklı farklı bir kılıç versin her 10 levelde
User prompt
100 levele kadar kılıçlar olsun istiyorum ekler misiniz ben ekleyeceğim görsellerini
User prompt
Eklemediniz
User prompt
100 levele kadar kılıçlar olsun istiyorum ekler misiniz
User prompt
100 levele kadar kılıçlar olsun
User prompt
Level 10 den sonra farklı canavarlar çıksın istiyorum ben yapacağım görsel
User prompt
Level 10 den sonra farklı canavarlar çıksın istiyorum
User prompt
Level 11 den sonra farklı canavarlar çıksın
User prompt
Boss çıkınca oyun çok kasıyor
User prompt
Boss bozuk yürüyor düzelt
User prompt
Boss bana yüzde 10 vursun
User prompt
Xp yüzde 1000 gelsin
User prompt
Status ve shopu beyaz ysp
User prompt
Levelin altındakileri daha kaliteli görüntü yap
User prompt
Leveli de xpin yanına koy
User prompt
Level altındakiler beyaz biraz daha saga getir
User prompt
Level altındakiler beyaz biraz daha s aga getir
User prompt
Level altındakiler biraz daha sola getir
User prompt
Levelin altındakileri beyaz yap hepsini biraz sola getir
User prompt
Status ve shopu biraz büyüt
User prompt
Shopu farklı bir yere koy mesala statusun yanına
User prompt
Shopun içindeki yazıları beyaz yap
User prompt
Shopu farklı bir yere koy ve arka plan ekle ben görsel yapacam
User prompt
Shopu farklı bir yere koy ve arka plan ekle ben görsel yapacam
User prompt
Her şeyi İngilizce yap
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var BombPowerUp = Container.expand(function () { var self = Container.call(this); // Define methods on self first 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 < self.magnetRadius) { // Magnet range for bomb // Move towards player self.x += dx / distance * self.magnetSpeed; self.y += dy / distance * self.magnetSpeed; if (distance < self.collectionDistance) { // Collection distance self.collect(); } } }; self.collect = function () { if (self.collected) return; self.collected = true; // Bomb explosion effect LK.effects.flashObject(self, 0xFF8C00, 300); // Flash orange for explosion // Consider adding an explosion sound if available: // LK.getSound('explosionSound').play(); for (var i = monsters.length - 1; i >= 0; i--) { var monster = monsters[i]; // Check if monster is valid and has position properties before calculating distance if (monster && typeof monster.x === 'number' && typeof monster.y === 'number') { // Calculate distance from the player to the monster for the explosion effect var distToMonster = Math.sqrt(Math.pow(player.x - monster.x, 2) + Math.pow(player.y - monster.y, 2)); if (distToMonster <= BOMB_EXPLOSION_RADIUS) { // Check if monster has takeDamage method if (typeof monster.takeDamage === 'function') { monster.takeDamage(BOMB_DAMAGE); } } } } var index = powerUpsArray.indexOf(self); if (index > -1) { powerUpsArray.splice(index, 1); } self.destroy(); }; // Properties and Asset Attachment var bombGraphics = self.attachAsset('bombPowerUpShape', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.magnetSpeed = 4; // Speed at which bomb moves towards player self.magnetRadius = 150; // Player distance to trigger magnet effect self.collectionDistance = 40; // Player distance to collect bomb return self; }); // 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 Lvl.' + 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); } } // Spawn a bomb with a 50% chance when the boss dies if (Math.random() < 0.5) { var bomb = new BombPowerUp(); // Spawn bomb near boss, slightly randomized bomb.x = self.x + (Math.random() * 60 - 30); bomb.y = self.y + (Math.random() * 60 - 30); game.addChild(bomb); powerUpsArray.push(bomb); } var index = monsters.indexOf(self); if (index > -1) { monsters.splice(index, 1); } // If this dying boss is the one being tracked, update state if (currentBossInstance === self) { currentBossInstance = null; game.bossActive = false; // Allows normal monster spawning to resume and stops boss-related checks } self.destroy(); }; self.update = function () { // Store lastX/lastY for good movement and event logic if (typeof self.lastX === "undefined") self.lastX = self.x; if (typeof self.lastY === "undefined") self.lastY = self.y; var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); // Move boss towards player, but clamp to not overshoot if (distance > 0) { var moveDist = Math.min(self.speed, distance); self.x += dx / distance * moveDist; self.y += dy / distance * moveDist; } // Boss attack logic: only trigger on entering attack range (not every frame) if (typeof self.lastDistance === "undefined") self.lastDistance = distance; if (self.lastDistance >= 100 && distance < 100) { player.hp -= player.maxHp * 0.10; // Boss deals 10% of player's max HP per hit if (player.hp <= 0) { LK.showGameOver(); } } self.lastX = self.x; self.lastY = self.y; self.lastDistance = distance; }; 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); } // Spawn a bomb with a 50% chance when a monster dies if (Math.random() < 0.5) { var bomb = new BombPowerUp(); bomb.x = self.x; bomb.y = self.y; game.addChild(bomb); powerUpsArray.push(bomb); } 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('Lvl.' + 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: 2.5, // Increased from 2.2 scaleY: 2.5 // Increased from 2.2 }); self.facing = "right"; // "right" or "left" self.playerGraphics = playerGraphics; // Save reference for flipping self.level = 1; self.xp = 0; self.xpToNext = 100; self.hp = 100; self.maxHp = 100; self.damage = 10; self.attackCooldown = 0; self.swordOffsetX = 25; // Horizontal offset for the sword from player's center self.swordOffsetY = 15; // Vertical offset for the sword from player's center (positive is down) 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, // Sword's hilt/origin is at its local x=0 anchorY: 0.5, // Sword's hilt/origin is vertically centered x: self.facing === "left" ? -self.swordOffsetX : self.swordOffsetX, // Positioned based on player's facing direction and offset y: self.swordOffsetY, // Vertically offset from player's center scaleX: 1.6, // Increase sword size scaleY: 1.6 // Increase sword size }); // Ensure sword sprite orientation matches player facing direction // This assumes sword assets are designed to point right with a positive scaleX if (self.facing === "left") { self.sword.scaleX = -Math.abs(self.sword.scaleX || 1); // Ensure scaleX is negative } else { self.sword.scaleX = Math.abs(self.sword.scaleX || 1); // Ensure scaleX is positive } }; 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 Points: ' + 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--; } // --- Flip player sprite based on movement direction --- if (typeof self.vx === "number" && Math.abs(self.vx) > 0.2) { if (self.vx > 0 && self.facing !== "right") { self.facing = "right"; if (self.playerGraphics) self.playerGraphics.scaleX = Math.abs(self.playerGraphics.scaleX); if (self.sword) { self.sword.scaleX = Math.abs(self.sword.scaleX || 1); self.sword.x = self.swordOffsetX; // Adjust sword position to right side } } else if (self.vx < 0 && self.facing !== "left") { self.facing = "left"; if (self.playerGraphics) self.playerGraphics.scaleX = -Math.abs(self.playerGraphics.scaleX); if (self.sword) { self.sword.scaleX = -Math.abs(self.sword.scaleX || 1); self.sword.x = -self.swordOffsetX; // Adjust sword position to left side } } } // 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 * 10); // XP increased by 1000% 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 ****/ // User will provide actual visual // OrangeRed ellipse for bomb // 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, width: 2048, height: 2732 })); var player; var monsters = []; var xpOrbs = []; var coinsArray = []; // Array to hold Coin instances var powerUpsArray = []; // Array to hold active power-ups like bombs var currentBossInstance = null; // Direct reference to the active boss instance var BOMB_DAMAGE = 50; // Damage dealt by a bomb explosion var BOMB_EXPLOSION_RADIUS = 200; // Radius of the bomb's explosion 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 = 200; levelText.y = 30; var xpText = new Text2('XP: 0/100', { size: 36, // Increased from 30 fill: 0xFFFFFF }); xpText.anchor.set(0, 0); LK.gui.topLeft.addChild(xpText); xpText.x = 200; xpText.y = 80; // Adjusted for new size var hpText = new Text2('HP: 100/100', { size: 36, // Increased from 30 fill: 0xFFFFFF }); hpText.anchor.set(0, 0); LK.gui.topLeft.addChild(hpText); hpText.x = 200; hpText.y = 130; // Adjusted for new size and spacing var coinText = new Text2('Coins: 0', { size: 36, // Increased from 30 fill: 0xFFFFFF }); coinText.anchor.set(0, 0); LK.gui.topLeft.addChild(coinText); coinText.x = 200; coinText.y = 180; // Adjusted for new size and spacing // Statü Menu Container var statusMenu = new Container(); LK.gui.center.addChild(statusMenu); statusMenu.visible = false; // Start hidden // Status Menu Background // Attach the background asset to the statusMenu. // By adding it here, before other elements are added to statusMenu, // it will be rendered underneath them. var statusMenuBg = statusMenu.attachAsset('statusMenuBackground', { anchorX: 0.5, // Center the background image horizontally anchorY: 0.5, // Center the background image vertically x: 0, // Position at the center of the statusMenu container y: 0 // Position at the center of the statusMenu container }); // Status Menu Title var statusMenuTitle = new Text2('Status Menu', { size: 60, // Increased from 48 fill: 0xFFFFFF }); statusMenuTitle.anchor.set(0.5, 0); statusMenuTitle.x = 0; statusMenuTitle.y = -280; // Adjusted from -260 statusMenu.addChild(statusMenuTitle); // Stats Text (moved to menu) var statusText = new Text2('Stats: ' + player.damage, { size: 42, // Increased from 36 fill: 0xFFFFFF }); statusText.anchor.set(0.5, 0); statusText.x = 0; statusText.y = -200; // Adjusted from -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('Power +', { size: 42, // Increased from 36 fill: 0xFFFFFF }); gucButton.anchor.set(0.5, 0); gucButton.x = -200; gucButton.y = -100; // Adjusted from -80 statusMenu.addChild(gucButton); var hizButton = new Text2('Speed +', { size: 42, // Increased from 36 fill: 0xFFFFFF }); hizButton.anchor.set(0.5, 0); hizButton.x = 0; hizButton.y = -100; // Adjusted from -80 statusMenu.addChild(hizButton); var canButton = new Text2('Health +', { size: 42, // Increased from 36 fill: 0xFFFFFF }); canButton.anchor.set(0.5, 0); canButton.x = 200; canButton.y = -100; // Adjusted from -80 statusMenu.addChild(canButton); var statPointText = new Text2('Stat Points: 0', { size: 38, // Increased from 32 fill: 0xFFFFFF }); statPointText.anchor.set(0.5, 0); statPointText.x = 0; statPointText.y = 0; // Remains at 0 statusMenu.addChild(statPointText); // Status Menu Close Button var closeStatusMenuButton = new Text2('Close', { size: 42, // Increased from 36 fill: 0xFFFFFF }); closeStatusMenuButton.anchor.set(0.5, 0); closeStatusMenuButton.x = 0; closeStatusMenuButton.y = 220; // Adjusted from 200 statusMenu.addChild(closeStatusMenuButton); closeStatusMenuButton.down = function () { statusMenu.visible = false; if (activeGuiMenu === statusMenu) activeGuiMenu = null; }; // Status Menu Open Button (always visible, top right) var openStatusMenuButton = new Text2('Status', { size: 48, // Increased from 36 fill: 0xFFFFFF }); 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 Points: ' + statPoints); } }; hizButton.down = function (x, y, obj) { if (statPoints > 0) { statHiz++; statPoints--; playerMaxSpeed += 1.2; statPointText.setText('Stat Points: ' + 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 Points: ' + statPoints); } }; // Stat button event handlers gucButton.down = function (x, y, obj) { if (statPoints > 0) { statGuc++; statPoints--; player.damage += 2; statPointText.setText('Stat Points: ' + statPoints); } }; hizButton.down = function (x, y, obj) { if (statPoints > 0) { statHiz++; statPoints--; playerMaxSpeed += 1.2; statPointText.setText('Stat Points: ' + 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 Points: ' + statPoints); } }; // Shop Menu Elements var shopMenu = new Container(); LK.gui.center.addChild(shopMenu); shopMenu.visible = false; // Start hidden // Shop Menu Background var shopMenuBg = shopMenu.attachAsset('shopMenuBackground', { anchorX: 0.5, // Center the background image horizontally anchorY: 0.5, // Center the background image vertically x: 0, // Position at the center of the shopMenu container y: 0 // Position at the center of the shopMenu container }); var shopMenuTitle = new Text2('Shop', { size: 60, // Increased from 48 fill: 0xFFFFFF }); shopMenuTitle.anchor.set(0.5, 0); shopMenuTitle.x = 0; shopMenuTitle.y = -280; // Adjusted from -260, Position above center shopMenu.addChild(shopMenuTitle); // Shop Item 1: Health Potion var buyHealthPotionButton = new Text2('Buy Health Potion (10 Coins)', { size: 42, // Increased from 36 fill: 0xFFFFFF }); buyHealthPotionButton.anchor.set(0.5, 0); buyHealthPotionButton.x = 0; buyHealthPotionButton.y = -200; // Adjusted from -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('Stats: ' + player.damage + ' | Speed: ' + Math.round(playerMaxSpeed * 10) / 10 + ' | Health: ' + 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('Buy Damage Boost (20 Coins)', { size: 42, // Increased from 36 fill: 0xFFFFFF }); buyDamageBoostButton.anchor.set(0.5, 0); buyDamageBoostButton.x = 0; buyDamageBoostButton.y = -120; // Adjusted from -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('Stats: ' + player.damage + ' | Speed: ' + Math.round(playerMaxSpeed * 10) / 10 + ' | Health: ' + Math.floor(player.hp)); } else { LK.effects.flashObject(buyDamageBoostButton, 0xFF0000, 300); // Flash red } }; // Shop Menu Close Button var closeShopMenuButton = new Text2('Close', { size: 42, // Increased from 36 fill: 0xFFFFFF }); closeShopMenuButton.anchor.set(0.5, 0); closeShopMenuButton.x = 0; closeShopMenuButton.y = 220; // Adjusted from 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('Shop', { size: 48, // Increased from 36 fill: 0xFFFFFF }); openShopMenuButton.anchor.set(1, 0); // Anchor to top-right for positioning LK.gui.topRight.addChild(openShopMenuButton); // Add to top right GUI area openShopMenuButton.x = -40; // Align with Status button horizontally (same X as status button) openShopMenuButton.y = openStatusMenuButton.y + openStatusMenuButton.height + 20; // Position below Status button (status.y(40) + new_status_size(48) + padding(20)) 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; } }; 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 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; } }; game.up = function (x, y, obj) { moveDirection.x = 0; moveDirection.y = 0; player.isMovingToTarget = false; }; 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 // Spawns a boss if not already active, player is at a boss level, and no current boss instance exists. if (!game.bossActive && player.level > 0 && player.level % 10 === 0) { // If game.bossActive is false, currentBossInstance should be null. // This check is simplified as game.bossActive is now reliably managed. var boss = new Boss(); // Spawn boss in the center of the map boss.x = 1024; boss.y = 600; game.addChild(boss); monsters.push(boss); currentBossInstance = boss; // Track the newly spawned boss game.bossActive = true; // Set the game to boss mode } // Only spawn normal monsters if not in a boss fight if (!game.bossActive) { spawnTimer++; if (spawnTimer >= 120) { spawnMonster(); spawnTimer = 0; } } // The 'else' block that previously checked if the boss was still alive by iterating // through the monsters array has been removed. // game.bossActive is now set to false directly in Boss.die() when the boss is defeated. // 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 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); } } // Update and clean up power-ups (e.g., bombs) for (var l = powerUpsArray.length - 1; l >= 0; l--) { var powerUp = powerUpsArray[l]; // The powerUp.update() is called by LK engine automatically if it's added to the game if (powerUp.x < -50 || powerUp.x > 2098 || powerUp.y < -50 || powerUp.y > 2782) { powerUp.destroy(); powerUpsArray.splice(l, 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('Stats: ' + player.damage + ' | Speed: ' + Math.round(playerMaxSpeed * 10) / 10 + ' | Health: ' + Math.floor(player.hp)); statPointText.setText('Stat Points: ' + statPoints); };
===================================================================
--- original.js
+++ change.js
@@ -155,8 +155,13 @@
var index = monsters.indexOf(self);
if (index > -1) {
monsters.splice(index, 1);
}
+ // If this dying boss is the one being tracked, update state
+ if (currentBossInstance === self) {
+ currentBossInstance = null;
+ game.bossActive = false; // Allows normal monster spawning to resume and stops boss-related checks
+ }
self.destroy();
};
self.update = function () {
// Store lastX/lastY for good movement and event logic
@@ -552,8 +557,9 @@
var monsters = [];
var xpOrbs = [];
var coinsArray = []; // Array to hold Coin instances
var powerUpsArray = []; // Array to hold active power-ups like bombs
+var currentBossInstance = null; // Direct reference to the active boss instance
var BOMB_DAMAGE = 50; // Damage dealt by a bomb explosion
var BOMB_EXPLOSION_RADIUS = 200; // Radius of the bomb's explosion
var coins = 0; // Variable to keep track of coins collected
var moveDirection = {
@@ -912,47 +918,32 @@
monsters.push(monster);
}
game.update = function () {
// Boss spawn logic
+ // Spawns a boss if not already active, player is at a boss level, and no current boss instance exists.
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;
- }
+ // If game.bossActive is false, currentBossInstance should be null.
+ // This check is simplified as game.bossActive is now reliably managed.
+ var boss = new Boss();
+ // Spawn boss in the center of the map
+ boss.x = 1024;
+ boss.y = 600;
+ game.addChild(boss);
+ monsters.push(boss);
+ currentBossInstance = boss; // Track the newly spawned boss
+ game.bossActive = true; // Set the game to boss mode
}
- // Only spawn normal monsters if not in boss fight
+ // Only spawn normal monsters if not in a 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;
- }
}
+ // The 'else' block that previously checked if the boss was still alive by iterating
+ // through the monsters array has been removed.
+ // game.bossActive is now set to false directly in Boss.die() when the boss is defeated.
// 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;
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