User prompt
The directions are reversed; please fix them.
User prompt
When the mouse moves downward, the character’s face should look downward; when the mouse moves upward, the character’s face should look upward. Currently, it’s reversed—please fix this.
User prompt
The up and down directions are reversed. Please swap them so the character faces up when the mouse is above, and faces down when the mouse is below.
User prompt
It’s currently reversed — when the mouse is pointing downward, the character looks upward. Please fix this so that when the mouse is below the character, the character faces downward, and when the mouse is above, the character faces upward.
User prompt
Also apply this for up and down directions: When the mouse is above the character, the character should face upward. When the mouse is below the character, the character should face downward.
User prompt
The character is currently facing the wrong direction — when the mouse is on the right, the character looks to the left. Fix this so that when the mouse is on the right, the character faces right, and when the mouse is on the left, the character faces left.
User prompt
Text fonts on the shop screen should be bold, and the text color should be black. The plus (+) button should be slightly larger and red in color. The main character should face the direction they are moving.
User prompt
When an upgrade is purchased in the shop, the cost to upgrade that same stat again should increase. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
shop ekranında bir özelliği güçlendirdiğimzde güçlendirdiğimiz özelliğin birdaha güçlendirmesi için harcanılan maliyet artsın
User prompt
Please slightly reduce the base costs of the shop upgrades. Also, the shop screen layout is a bit broken — the texts are overlapping. Please fix the layout and spacing so everything is clearly readable.
User prompt
The shop screen opens, but I cannot click or select anything on it. The game freezes, and I cannot close the opened shop screen. Please fix this issue.
User prompt
When a coin enters the circular attack range around the character, it should be pulled toward the character more slowly. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When a coin enters the circular attack range around the character, it should slowly be pulled toward the character. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Coins within the character’s range should be attracted toward the main character and collected automatically. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Coins that are within the character’s range should slowly be pulled toward the character. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When an enemy character touches the player, it should be pushed back by a very small amount. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Health packs and coins must be collected exactly at the moment the character physically touches them — not before or after.
User prompt
Health packs should rotate around their own Y-axis. Uncollected health packs should disappear after 1 minute. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Coins should rotate around their own Y-axis. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Each coin that is not collected from the ground should disappear after 30 seconds ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Each coin that is not collected from the ground should disappear after 30 seconds. Coins on the ground should rotate around their own axis ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Coins on the ground from the current level should disappear when the player moves to the next level.
User prompt
Buttons on the shop screen should be clickable.
User prompt
Health packs should rarely drop only from enemies, and only when they are killed. They should not appear from any other source.
User prompt
The shop screen should open every 5 levels. A boss should appear every 10 levels. The boss should be able to shoot and its health should increase every 10 levels. Collectible coins should be collected when the character touches them. Health packs should drop rarely, with a chance to drop in every level.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = 300 + (currentLevel - 10) * 50;
self.health = self.maxHealth;
self.speed = 0.8 + (currentLevel - 10) * 0.1;
self.damage = 30 + (currentLevel - 10) * 8;
self.lastAttack = 0;
self.attackCooldown = 60;
self.update = function () {
if (gameState === 'playing' && player) {
// Move towards player
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;
}
// Attack player on physical contact only
self.lastAttack++;
if (self.lastAttack >= self.attackCooldown) {
// Shoot bullet at player
var bullet = new BossBullet();
bullet.x = self.x;
bullet.y = self.y;
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
bullet.velocityX = dx / distance * 6;
bullet.velocityY = dy / distance * 6;
}
bossBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
self.lastAttack = 0;
}
}
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff0000, 200);
if (self.health <= 0) {
self.die();
}
};
self.die = function () {
// Drop multiple coins with value based on current level
for (var i = 0; i < 5; i++) {
var coin = new Coin();
coin.value = currentLevel * 2; // Boss coins worth 2x level value
coin.x = self.x + (Math.random() - 0.5) * 100;
coin.y = self.y + (Math.random() - 0.5) * 100;
coins.push(coin);
game.addChild(coin);
}
currentBoss = null;
self.destroy();
// Show body part selection
showBodyPartSelection();
};
return self;
});
var BossBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.damage = 15;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
// Remove if off screen
if (self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782) {
self.removeFromGame();
}
// Check collision with player using precise distance calculation
if (player) {
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var collisionDistance = (player.width + self.width) / 8; // Tight collision bounds
if (distance <= collisionDistance) {
player.takeDamage(self.damage);
self.removeFromGame();
}
}
};
self.removeFromGame = function () {
for (var i = 0; i < bossBullets.length; i++) {
if (bossBullets[i] === self) {
bossBullets.splice(i, 1);
break;
}
}
self.destroy();
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.value = 10;
self.update = function () {
if (player) {
// Only collect on precise physical contact using distance calculation
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var collectionDistance = (player.width + self.width) / 4; // Tight collision bounds for collection
if (distance <= collectionDistance) {
playerCoins += self.value;
coinText.setText('Coins: ' + playerCoins);
LK.getSound('coinCollect').play();
// Remove from coins array
for (var i = 0; i < coins.length; i++) {
if (coins[i] === self) {
coins.splice(i, 1);
break;
}
}
self.destroy();
}
}
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 40 + (currentLevel - 1) * 8;
self.speed = 1.5 + (currentLevel - 1) * 0.15;
self.damage = 10 * (1 + (currentLevel - 1) * 0.1);
self.lastAttack = 0;
self.attackCooldown = 120;
self.update = function () {
if (gameState === 'playing' && player) {
// Move towards player
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;
}
// Attack player on physical contact only
self.lastAttack++;
if (self.lastAttack >= self.attackCooldown) {
// Only damage on direct collision using precise distance calculation
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var collisionDistance = (player.width + self.width) / 8; // Much tighter collision bounds
if (distance <= collisionDistance) {
player.takeDamage(self.damage);
self.lastAttack = 0;
}
}
}
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff0000, 200);
if (self.health <= 0) {
self.die();
}
};
self.die = function () {
// Drop coin with value based on current level
var coin = new Coin();
coin.value = currentLevel; // Scale coin value with level
coin.x = self.x;
coin.y = self.y;
coins.push(coin);
game.addChild(coin);
// Rarely drop health pack (5% chance)
if (Math.random() < 0.05) {
var healthPack = new HealthPack();
healthPack.x = self.x + (Math.random() - 0.5) * 60;
healthPack.y = self.y + (Math.random() - 0.5) * 60;
healthPacks.push(healthPack);
game.addChild(healthPack);
}
// Remove from enemies array
for (var i = 0; i < enemies.length; i++) {
if (enemies[i] === self) {
enemies.splice(i, 1);
break;
}
}
self.destroy();
enemiesKilled++;
};
return self;
});
var HealthPack = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('healthPack', {
anchorX: 0.5,
anchorY: 0.5
});
self.healAmount = 0.15; // 15% of max health
self.update = function () {
if (player && self.intersects(player) && player.health < player.maxHealth) {
var healValue = Math.floor(player.maxHealth * self.healAmount);
player.health = Math.min(player.maxHealth, player.health + healValue);
LK.getSound('coinCollect').play();
// Remove from healthPacks array
for (var i = 0; i < healthPacks.length; i++) {
if (healthPacks[i] === self) {
healthPacks.splice(i, 1);
break;
}
}
self.destroy();
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Add attack range visual
var rangeGraphics = self.attachAsset('attackRange', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.2,
width: 600,
// 300 radius * 2
height: 600 // 300 radius * 2
});
self.maxHealth = 30;
self.health = self.maxHealth;
self.speed = 2.0;
self.damage = 5;
self.attackSpeed = 120;
self.attackRange = 300; // Base attack range radius
self.lastShot = 0;
self.update = function () {
if (gameState === 'playing') {
// Move towards touch position if touching
if (touchPosition && (Math.abs(self.x - touchPosition.x) > 5 || Math.abs(self.y - touchPosition.y) > 5)) {
var dx = touchPosition.x - self.x;
var dy = touchPosition.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;
}
}
// Auto-shoot when enemies are in range
self.lastShot++;
var target = self.findNearestEnemy();
if (self.lastShot >= self.attackSpeed && target) {
self.shoot();
self.lastShot = 0;
}
}
};
self.shoot = function () {
var target = self.findNearestEnemy();
if (target) {
var bullet = new PlayerBullet();
bullet.x = self.x;
bullet.y = self.y;
var dx = target.x - self.x;
var dy = target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
bullet.velocityX = dx / distance * 8;
bullet.velocityY = dy / distance * 8;
playerBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
};
self.findNearestEnemy = function () {
if (currentBoss) {
var dx = currentBoss.x - self.x;
var dy = currentBoss.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= self.attackRange) return currentBoss;
}
var nearest = null;
var nearestDistance = Infinity;
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
var dx = enemy.x - self.x;
var dy = enemy.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= self.attackRange && distance < nearestDistance) {
nearestDistance = distance;
nearest = enemy;
}
}
return nearest;
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff0000, 300);
if (self.health <= 0) {
LK.showGameOver();
}
};
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.damage = 20;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
// Remove if off screen
if (self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782) {
self.removeFromGame();
}
// Check collision with enemies
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
if (self.intersects(enemy)) {
enemy.takeDamage(self.damage + player.damage);
LK.getSound('enemyHit').play();
self.removeFromGame();
return;
}
}
// Check collision with boss
if (currentBoss && self.intersects(currentBoss)) {
currentBoss.takeDamage(self.damage + player.damage);
LK.getSound('enemyHit').play();
self.removeFromGame();
}
};
self.removeFromGame = function () {
for (var i = 0; i < playerBullets.length; i++) {
if (playerBullets[i] === self) {
playerBullets.splice(i, 1);
break;
}
}
self.destroy();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Game variables
var gameState = 'playing'; // 'playing', 'shop', 'bodyPartSelection'
var currentLevel = 1;
var enemiesKilled = 0;
var enemiesPerLevel = 5;
var playerCoins = 0;
var touchPosition = null;
// Player upgrade levels and costs
var healthUpgradeLevel = 0;
var attackSpeedUpgradeLevel = 0;
var attackPowerUpgradeLevel = 0;
var movementSpeedUpgradeLevel = 0;
var attackRangeUpgradeLevel = 0;
// Game objects
var player = null;
var enemies = [];
var playerBullets = [];
var bossBullets = [];
var coins = [];
var healthPacks = [];
var currentBoss = null;
// UI elements
var levelText = new Text2('Level: 1', {
size: 60,
fill: 0xFFFFFF
});
levelText.anchor.set(0, 0);
levelText.x = 50;
levelText.y = 50;
LK.gui.topLeft.addChild(levelText);
var healthText = new Text2('Health: 30', {
size: 50,
fill: 0xE74C3C
});
healthText.anchor.set(0.5, 0);
healthText.x = 0;
healthText.y = 50;
LK.gui.top.addChild(healthText);
var coinText = new Text2('Coins: 0', {
size: 40,
fill: 0xF1C40F
});
coinText.anchor.set(1, 0);
coinText.x = -50;
coinText.y = 50;
LK.gui.topRight.addChild(coinText);
// Stats display in top-right corner
var statsContainer = new Container();
var healthStatText = new Text2('Health: 30', {
size: 35,
fill: 0xE74C3C
});
healthStatText.anchor.set(1, 0);
healthStatText.x = -50;
healthStatText.y = 100;
var attackPowerStatText = new Text2('Attack: 5', {
size: 35,
fill: 0xFF6B6B
});
attackPowerStatText.anchor.set(1, 0);
attackPowerStatText.x = -50;
attackPowerStatText.y = 140;
var attackSpeedStatText = new Text2('A.Speed: 120', {
size: 35,
fill: 0x4ECDC4
});
attackSpeedStatText.anchor.set(1, 0);
attackSpeedStatText.x = -50;
attackSpeedStatText.y = 180;
var movementSpeedStatText = new Text2('M.Speed: 2.0', {
size: 35,
fill: 0x45B7D1
});
movementSpeedStatText.anchor.set(1, 0);
movementSpeedStatText.x = -50;
movementSpeedStatText.y = 220;
var attackRangeStatText = new Text2('Range: 600', {
size: 35,
fill: 0x9B59B6
});
attackRangeStatText.anchor.set(1, 0);
attackRangeStatText.x = -50;
attackRangeStatText.y = 260;
LK.gui.topRight.addChild(healthStatText);
LK.gui.topRight.addChild(attackPowerStatText);
LK.gui.topRight.addChild(attackSpeedStatText);
LK.gui.topRight.addChild(movementSpeedStatText);
LK.gui.topRight.addChild(attackRangeStatText);
// Shop UI (hidden initially)
var shopContainer = new Container();
var shopBackground = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 6,
x: 0,
y: 0
});
shopContainer.addChild(shopBackground);
var shopTitle = new Text2('SHOP', {
size: 80,
fill: 0xFFFFFF
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 0;
shopTitle.y = -200;
shopContainer.addChild(shopTitle);
var upgradeButtons = [];
var upgradeLabels = [];
var upgradePlusButtons = [];
var upgradeCostLabels = [];
var upgradeNames = ['Health +15', 'Attack Speed +', 'Attack Power +8', 'Move Speed +0.8', 'Range +20'];
for (var i = 0; i < 5; i++) {
var buttonBg = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: -100 + i * 80
});
shopContainer.addChild(buttonBg);
upgradeButtons.push(buttonBg);
var label = new Text2(upgradeNames[i], {
size: 35,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
label.x = -100;
label.y = -100 + i * 80;
shopContainer.addChild(label);
upgradeLabels.push(label);
// Plus button for each upgrade
var plusButton = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4,
x: 150,
y: -100 + i * 80
});
shopContainer.addChild(plusButton);
upgradePlusButtons.push(plusButton);
// Plus text
var plusText = new Text2('+', {
size: 40,
fill: 0xFFFFFF
});
plusText.anchor.set(0.5, 0.5);
plusText.x = 150;
plusText.y = -100 + i * 80;
shopContainer.addChild(plusText);
// Cost label
var costLabel = new Text2('Cost: 0', {
size: 25,
fill: 0xF1C40F
});
costLabel.anchor.set(0.5, 0.5);
costLabel.x = 250;
costLabel.y = -100 + i * 80;
shopContainer.addChild(costLabel);
upgradeCostLabels.push(costLabel);
}
var closeShopButton = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 200,
scaleX: 0.8,
scaleY: 0.8
});
shopContainer.addChild(closeShopButton);
var closeShopText = new Text2('X CLOSE', {
size: 50,
fill: 0xFFFFFF
});
closeShopText.anchor.set(0.5, 0.5);
closeShopText.x = 0;
closeShopText.y = 200;
shopContainer.addChild(closeShopText);
shopContainer.x = 1024;
shopContainer.y = 1366;
shopContainer.visible = false;
// Body part selection UI (hidden initially)
var bodyPartContainer = new Container();
var bodyPartBackground = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 10,
scaleY: 8,
x: 0,
y: 0
});
bodyPartContainer.addChild(bodyPartBackground);
var bodyPartTitle = new Text2('CHOOSE BODY PART', {
size: 70,
fill: 0xFFFFFF
});
bodyPartTitle.anchor.set(0.5, 0.5);
bodyPartTitle.x = 0;
bodyPartTitle.y = -250;
bodyPartContainer.addChild(bodyPartTitle);
var bodyPartButtons = [];
for (var i = 0; i < 3; i++) {
var partButton = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -100 + i * 120
});
bodyPartContainer.addChild(partButton);
bodyPartButtons.push(partButton);
}
bodyPartContainer.x = 1024;
bodyPartContainer.y = 1366;
bodyPartContainer.visible = false;
game.addChild(shopContainer);
game.addChild(bodyPartContainer);
// Initialize player
player = new Player();
player.x = 1024;
player.y = 1366;
game.addChild(player);
// Spawn initial enemies
function spawnEnemies() {
var enemiesToSpawn = Math.floor(enemiesPerLevel * (1 + Math.floor((currentLevel - 1) / 5) * 0.25));
for (var i = 0; i < enemiesToSpawn; i++) {
var enemy = new Enemy();
// Spawn from edges
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
enemy.x = Math.random() * 2048;
enemy.y = -50;
break;
case 1:
// Right
enemy.x = 2098;
enemy.y = Math.random() * 2732;
break;
case 2:
// Bottom
enemy.x = Math.random() * 2048;
enemy.y = 2782;
break;
case 3:
// Left
enemy.x = -50;
enemy.y = Math.random() * 2732;
break;
}
enemies.push(enemy);
game.addChild(enemy);
}
}
function spawnBoss() {
currentBoss = new Boss();
currentBoss.x = 1024;
currentBoss.y = 200;
game.addChild(currentBoss);
}
function showShop() {
gameState = 'shop';
shopContainer.visible = true;
updateShopDisplay();
// Pause all game objects
for (var i = 0; i < enemies.length; i++) {
enemies[i].visible = false;
}
}
function updateShopDisplay() {
var baseCosts = [30, 40, 50, 35, 45];
var upgradeLevels = [healthUpgradeLevel, attackSpeedUpgradeLevel, attackPowerUpgradeLevel, movementSpeedUpgradeLevel, attackRangeUpgradeLevel];
var anyAffordable = false;
for (var i = 0; i < 5; i++) {
var cost = baseCosts[i] + upgradeLevels[i] * 20;
upgradeCostLabels[i].setText('Cost: ' + cost);
// Enable/disable plus button based on affordability
if (playerCoins >= cost) {
upgradePlusButtons[i].visible = true;
upgradePlusButtons[i].alpha = 1.0;
anyAffordable = true;
} else {
upgradePlusButtons[i].visible = true;
upgradePlusButtons[i].alpha = 0.3;
}
}
// Show/hide close button based on affordability
if (!anyAffordable) {
closeShopButton.visible = true;
closeShopText.visible = true;
} else {
closeShopButton.visible = true;
closeShopText.visible = true;
}
}
function hideShop() {
gameState = 'playing';
shopContainer.visible = false;
// Resume all game objects
for (var i = 0; i < enemies.length; i++) {
enemies[i].visible = true;
}
}
function showBodyPartSelection() {
gameState = 'bodyPartSelection';
bodyPartContainer.visible = true;
}
function hideBodyPartSelection() {
gameState = 'playing';
bodyPartContainer.visible = false;
// Level progression is now handled in game.update
enemiesKilled = 0;
spawnEnemies();
}
// Event handlers
game.down = function (x, y, obj) {
touchPosition = {
x: x,
y: y
};
if (gameState === 'shop') {
// Check shop button clicks
var shopPos = shopContainer.toLocal({
x: x,
y: y
});
// Check plus buttons
for (var i = 0; i < upgradePlusButtons.length; i++) {
var plusButton = upgradePlusButtons[i];
if (plusButton.visible && Math.abs(shopPos.x - plusButton.x) < 80 && Math.abs(shopPos.y - plusButton.y) < 40) {
var baseCosts = [30, 40, 50, 35, 45];
var upgradeLevels = [healthUpgradeLevel, attackSpeedUpgradeLevel, attackPowerUpgradeLevel, movementSpeedUpgradeLevel, attackRangeUpgradeLevel];
var cost = baseCosts[i] + upgradeLevels[i] * 20;
if (playerCoins >= cost) {
purchaseUpgrade(i);
updateShopDisplay();
}
return;
}
}
// Check close button
if (Math.abs(shopPos.x - closeShopButton.x) < 160 && Math.abs(shopPos.y - closeShopButton.y) < 64) {
hideShop();
spawnEnemies();
}
}
if (gameState === 'bodyPartSelection') {
// Check body part button clicks
var bodyPos = bodyPartContainer.toLocal({
x: x,
y: y
});
for (var i = 0; i < bodyPartButtons.length; i++) {
var button = bodyPartButtons[i];
if (Math.abs(bodyPos.x - button.x) < 200 && Math.abs(bodyPos.y - button.y) < 80) {
selectBodyPart(i);
hideBodyPartSelection();
return;
}
}
}
};
game.move = function (x, y, obj) {
if (gameState === 'playing') {
touchPosition = {
x: x,
y: y
};
}
};
game.up = function (x, y, obj) {
touchPosition = null;
};
function purchaseUpgrade(upgradeIndex) {
var baseCosts = [30, 40, 50, 35, 45];
var upgradeLevels = [healthUpgradeLevel, attackSpeedUpgradeLevel, attackPowerUpgradeLevel, movementSpeedUpgradeLevel, attackRangeUpgradeLevel];
var cost = baseCosts[upgradeIndex] + upgradeLevels[upgradeIndex] * 20;
if (playerCoins >= cost) {
playerCoins -= cost;
coinText.setText('Coins: ' + playerCoins);
switch (upgradeIndex) {
case 0:
// Health upgrade
healthUpgradeLevel++;
player.maxHealth += 15;
player.health = player.maxHealth;
break;
case 1:
// Attack Speed upgrade
attackSpeedUpgradeLevel++;
player.attackSpeed = Math.max(10, player.attackSpeed - 5);
break;
case 2:
// Attack Power upgrade
attackPowerUpgradeLevel++;
player.damage += 8;
break;
case 3:
// Movement Speed upgrade
movementSpeedUpgradeLevel++;
player.speed += 0.8;
break;
case 4:
// Attack Range upgrade
attackRangeUpgradeLevel++;
player.attackRange += 20;
// Update visual range circle
var rangeGraphics = player.children[1]; // Second child is the range circle
rangeGraphics.width = player.attackRange * 2;
rangeGraphics.height = player.attackRange * 2;
break;
}
updateStatsDisplay();
}
}
function updateStatsDisplay() {
healthStatText.setText('Health: ' + player.maxHealth);
attackPowerStatText.setText('Attack: ' + player.damage);
attackSpeedStatText.setText('A.Speed: ' + (130 - player.attackSpeed));
movementSpeedStatText.setText('M.Speed: ' + player.speed.toFixed(1));
attackRangeStatText.setText('Range: ' + player.attackRange * 2);
}
function selectBodyPart(partIndex) {
switch (partIndex) {
case 0:
// Strong Arms - More damage
player.damage += 25;
player.scaleX *= 1.1;
break;
case 1:
// Swift Legs - More speed
player.speed += 2;
player.scaleY *= 1.1;
break;
case 2:
// Tough Body - More health
player.maxHealth += 50;
player.health = player.maxHealth;
player.scaleX *= 1.05;
player.scaleY *= 1.05;
break;
}
}
// Spawn initial enemies
spawnEnemies();
game.update = function () {
// Update health display
healthText.setText('Health: ' + player.health);
// Update stats display
updateStatsDisplay();
// Check if all enemies are defeated
if (gameState === 'playing' && enemies.length === 0 && !currentBoss) {
// Progress to next level
currentLevel++;
levelText.setText('Level: ' + currentLevel);
enemiesKilled = 0;
// Clear all coins from the ground when moving to next level
for (var i = coins.length - 1; i >= 0; i--) {
coins[i].destroy();
coins.splice(i, 1);
}
if (currentLevel % 10 === 0) {
// Boss level every 10 levels
spawnBoss();
} else if (currentLevel % 5 === 0) {
// Shop level every 5 levels (but not on boss levels)
showShop();
} else {
// Regular level
spawnEnemies();
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -837,8 +837,13 @@
// Progress to next level
currentLevel++;
levelText.setText('Level: ' + currentLevel);
enemiesKilled = 0;
+ // Clear all coins from the ground when moving to next level
+ for (var i = coins.length - 1; i >= 0; i--) {
+ coins[i].destroy();
+ coins.splice(i, 1);
+ }
if (currentLevel % 10 === 0) {
// Boss level every 10 levels
spawnBoss();
} else if (currentLevel % 5 === 0) {
coin. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
health pack. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
scary toothed germ style enemy. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
cloud. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
emerald. In-Game asset. 2d. High contrast. No shadows
blue hand granade. In-Game asset. 2d. High contrast. No shadows
a green scary ball with metal teeth. In-Game asset. 2d. High contrast. No shadows
green poison ball. In-Game asset. 2d. High contrast. No shadows
machine gun. In-Game asset. 2d. High contrast. No shadows
machine gun bullet. In-Game asset. 2d. High contrast. No shadows
rocket launcher. In-Game asset. 2d. High contrast. No shadows
horizontal rocket bullet. In-Game asset. 2d. High contrast. No shadows
treasure chest. In-Game asset. 2d. High contrast. No shadows
vaccine with a plus sign. In-Game asset. 2d. High contrast. No shadows
blue steel vest. In-Game asset. 2d. High contrast. No shadows
u magnet. In-Game asset. 2d. High contrast. No shadows
red shoes with a 2x. In-Game asset. 2d. High contrast. No shadows
horizontal needle. In-Game asset. 2d. High contrast. No shadows
horizontal fire ball. In-Game asset. 2d. High contrast. No shadows
blue
pink blue black and orange mixed horizontal fire ball. In-Game asset. 2d. High contrast. No shadows
robot virüs. In-Game asset. 2d. High contrast. No shadows
artı işareti yeşil olsun bu artı işareti tedavi artı işareti yukarıda boyadığım kısım kırmızı olsun
metal kaplı görünsün
amber stone. In-Game asset. 2d. High contrast. No shadows
rengi mor olsun