User prompt
Coins should be collected from the ground when the character touches them.
User prompt
Every enemy I kill should drop 1 coin, but this amount should increase according to the current level.
User prompt
My character’s health should decrease only when touching an enemy. Enemies entering the attack range should not reduce my character’s health.
User prompt
There is an issue where the enemy causes damage to my main character without actually touching them. The main character’s health should decrease only at the precise moment of sensitive physical contact with the enemy.
User prompt
Enemies get very close to the character but do not physically touch, yet the character's health decreases. I want the damage to be precise—health should decrease only at the exact moment of physical contact with the character.
User prompt
Enemies entering the character's range should not reduce the character's health. The character's health should decrease only when enemies physically touch the character.
User prompt
The player's health should decrease only when the player physically contacts an enemy character. Health should not decrease when an enemy enters the player's attack range area.
User prompt
The player should only take damage when there is direct physical contact with an enemy (i.e., collision between the player and enemy objects). Simply having an enemy enter the player’s attack range (the circular radius) must not cause any damage to the player. This encourages the player to maintain distance and avoid contact.
User prompt
Coin Collection by Contact Only Coins should be collected only when the player physically touches them (collides with them). Being within the attack range should NOT trigger collection. Use collision detection (e.g., OnTriggerEnter2D or OnCollisionEnter2D in Unity) between the player and coin objects to collect coins. Damage on Enemy Contact Only The player should take damage only when an enemy physically touches (collides with) the character. Simply being inside the player’s range or close proximity should not cause damage. This encourages the player to dodge enemies and manage spacing more carefully.
User prompt
Increase Starting Range The initial attack range should be larger than the current value of 200 units. For example, you can increase it to 300 units (or any value that feels balanced in gameplay). This allows the player to start engaging enemies from a more comfortable distance, improving early-game feel. Auto-Fire on Enemy Detection When an enemy enters the attack range, the character should automatically begin firing at the enemy. The attack should stop when there are no enemies inside the range. Optionally, the system can prioritize: The closest enemy in range. Or the first one that entered the range (depending on gameplay style).
User prompt
Health Pack Drops Occasionally, enemies will drop health packs when they are defeated. If the player has lost health, collecting a health pack will restore a portion of their max HP (e.g., 10–20%). The restored health cannot exceed the character’s max HP. Enemy Spawn Scaling Every 5 levels, the number of enemies per wave increases by a certain percentage (e.g., 20–30%). This creates a progressive challenge as the player advances. New Stat: Attack Range The character will now have a circular attack range, visualized as a circle around the player. The character will automatically start attacking when enemies enter this range. This attack range is upgradeable via the shop. Each upgrade will slightly increase the radius of the circle. The increase should be small and incremental to maintain balance. Range Display The diameter of the attack range should be shown in the top-right corner of the screen, along with other stats.
User prompt
Player Movement (Starting Speed) The character should move slightly faster at the start than originally planned. This is to make the game feel more responsive early on, while still allowing speed upgrades to remain meaningful. Enemy Damage Scaling At level 1, all enemies should deal exactly 10 damage per hit. With each new level, the damage dealt by enemies should increase at a reasonable rate — for example: Use a formula like: enemyDamage = baseDamage * (1 + level * 0.1) So at level 2: 10 * (1 + 0.1) = 11 At level 3: 10 * (1 + 0.2) = 12, and so on. This provides a gradual but noticeable difficulty curve.
User prompt
When the shop screen opens, the player should be able to interact with it. All UI elements (such as the plus (+) and close (X) buttons) must be clickable and responsive. The rest of the game should be paused while the shop is open, allowing the player to focus on upgrades. With each new level, the enemies should become stronger. This can include increased health, movement speed, and attack damage (if enemies attack). The progression should be balanced so the player feels increasing challenge and is motivated to upgrade their character. The character’s initial attack speed should be reduced even more, making them attack slower at the beginning, so that attack speed upgrades feel impactful and necessary.
User prompt
On the shop screen, there will be a “plus (+)” button next to each stat. As long as the player has enough coins, these plus buttons will be clickable. When the player clicks a plus button, it upgrades the corresponding stat on the character (Health, Attack Speed, etc.), and the coins are deducted accordingly. If the player no longer has enough coins, the plus buttons become disabled or disappear, making them unclickable. When the player runs out of coins and can no longer purchase upgrades: A “close (X)” button will appear on the screen. Clicking this X button will close the shop screen and the game will continue from where it left off.
User prompt
Let’s design it this way: In the shop, there will be four upgradeable stats: Health Upgrade – Increases the character’s maximum health. Attack Speed Upgrade – Increases how fast the character can attack. Attack Power Upgrade – Increases the damage dealt per attack. Movement Speed Upgrade – Increases how fast the character can move. Each upgrade will give a small improvement, but the cost of each upgrade will increase every time it is purchased. The main character should start very weak — with low health, slow movement, slow attack speed, and low damage. The goal for the player is to improve the character over time using the coins collected from defeated enemies. The character’s current stats (Health, Attack Power, Attack Speed, Movement Speed) should be visible in the top-right corner of the screen, updating as the player makes upgrades.
Code edit (1 edits merged)
Please save this source code
User prompt
Body Parts Collector
Initial prompt
I want you to make a game for me. Here's how the game will work: There will be a main character who is weak at the beginning. However, as the character defeats enemies, they will collect coins dropped by those enemies. After a certain number of rounds, a shop will appear where the player can spend those coins to buy upgrades. Additionally, every 10 levels, a boss will appear. If the player defeats the boss, they will be able to choose one of three body parts dropped by the boss to strengthen their character.
/****
* 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;
self.health = self.maxHealth;
self.speed = 0.8;
self.damage = 30;
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
self.lastAttack++;
if (distance < 150 && self.lastAttack >= self.attackCooldown) {
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 multiple coins
for (var i = 0; i < 5; i++) {
var coin = new Coin();
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 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 && self.intersects(player)) {
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;
self.speed = 1.5;
self.damage = 15;
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 if close enough
self.lastAttack++;
if (distance < 100 && self.lastAttack >= self.attackCooldown) {
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
var coin = new Coin();
coin.x = self.x;
coin.y = self.y;
coins.push(coin);
game.addChild(coin);
// 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 Player = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = 100;
self.health = self.maxHealth;
self.speed = 4;
self.damage = 20;
self.attackSpeed = 30;
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
self.lastShot++;
if (self.lastShot >= self.attackSpeed && (enemies.length > 0 || currentBoss)) {
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) 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 < 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;
// Game objects
var player = null;
var enemies = [];
var playerBullets = [];
var coins = [];
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: 100', {
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: 50,
fill: 0xF1C40F
});
coinText.anchor.set(1, 0);
coinText.x = -50;
coinText.y = 50;
LK.gui.topRight.addChild(coinText);
// 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 = [];
for (var i = 0; i < 3; i++) {
var buttonBg = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -50 + i * 100
});
shopContainer.addChild(buttonBg);
upgradeButtons.push(buttonBg);
}
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('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 = enemiesPerLevel + Math.floor(currentLevel / 5);
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;
// Pause all game objects
for (var i = 0; i < enemies.length; i++) {
enemies[i].visible = false;
}
}
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;
// Progress to next level
currentLevel++;
levelText.setText('Level: ' + currentLevel);
enemiesKilled = 0;
// Show shop every 5 levels (except boss levels)
if (currentLevel % 5 === 0 && currentLevel % 10 !== 0) {
showShop();
} else {
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 upgrade buttons
for (var i = 0; i < upgradeButtons.length; i++) {
var button = upgradeButtons[i];
if (Math.abs(shopPos.x - button.x) < 100 && Math.abs(shopPos.y - button.y) < 40) {
purchaseUpgrade(i);
return;
}
}
// Check close button
if (Math.abs(shopPos.x - closeShopButton.x) < 80 && Math.abs(shopPos.y - closeShopButton.y) < 32) {
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) < 100 && Math.abs(bodyPos.y - button.y) < 40) {
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 costs = [50, 100, 150];
var cost = costs[upgradeIndex];
if (playerCoins >= cost) {
playerCoins -= cost;
coinText.setText('Coins: ' + playerCoins);
switch (upgradeIndex) {
case 0:
// Health upgrade
player.maxHealth += 20;
player.health = player.maxHealth;
break;
case 1:
// Damage upgrade
player.damage += 10;
break;
case 2:
// Speed upgrade
player.speed += 1;
break;
}
}
}
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);
// Check if all enemies are defeated
if (gameState === 'playing' && enemies.length === 0 && !currentBoss) {
if (currentLevel % 10 === 0) {
// Boss level
spawnBoss();
} else if (currentLevel % 5 === 0) {
// Shop level
showShop();
} else {
// Next level
currentLevel++;
levelText.setText('Level: ' + currentLevel);
enemiesKilled = 0;
spawnEnemies();
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,588 @@
-/****
+/****
+* 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;
+ self.health = self.maxHealth;
+ self.speed = 0.8;
+ self.damage = 30;
+ 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
+ self.lastAttack++;
+ if (distance < 150 && self.lastAttack >= self.attackCooldown) {
+ 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 multiple coins
+ for (var i = 0; i < 5; i++) {
+ var coin = new Coin();
+ 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 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 && self.intersects(player)) {
+ 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;
+ self.speed = 1.5;
+ self.damage = 15;
+ 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 if close enough
+ self.lastAttack++;
+ if (distance < 100 && self.lastAttack >= self.attackCooldown) {
+ 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
+ var coin = new Coin();
+ coin.x = self.x;
+ coin.y = self.y;
+ coins.push(coin);
+ game.addChild(coin);
+ // 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 Player = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.maxHealth = 100;
+ self.health = self.maxHealth;
+ self.speed = 4;
+ self.damage = 20;
+ self.attackSpeed = 30;
+ 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
+ self.lastShot++;
+ if (self.lastShot >= self.attackSpeed && (enemies.length > 0 || currentBoss)) {
+ 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) 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 < 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: 0x000000
-});
\ No newline at end of file
+ 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;
+// Game objects
+var player = null;
+var enemies = [];
+var playerBullets = [];
+var coins = [];
+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: 100', {
+ 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: 50,
+ fill: 0xF1C40F
+});
+coinText.anchor.set(1, 0);
+coinText.x = -50;
+coinText.y = 50;
+LK.gui.topRight.addChild(coinText);
+// 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 = [];
+for (var i = 0; i < 3; i++) {
+ var buttonBg = LK.getAsset('shopButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: -50 + i * 100
+ });
+ shopContainer.addChild(buttonBg);
+ upgradeButtons.push(buttonBg);
+}
+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('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 = enemiesPerLevel + Math.floor(currentLevel / 5);
+ 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;
+ // Pause all game objects
+ for (var i = 0; i < enemies.length; i++) {
+ enemies[i].visible = false;
+ }
+}
+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;
+ // Progress to next level
+ currentLevel++;
+ levelText.setText('Level: ' + currentLevel);
+ enemiesKilled = 0;
+ // Show shop every 5 levels (except boss levels)
+ if (currentLevel % 5 === 0 && currentLevel % 10 !== 0) {
+ showShop();
+ } else {
+ 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 upgrade buttons
+ for (var i = 0; i < upgradeButtons.length; i++) {
+ var button = upgradeButtons[i];
+ if (Math.abs(shopPos.x - button.x) < 100 && Math.abs(shopPos.y - button.y) < 40) {
+ purchaseUpgrade(i);
+ return;
+ }
+ }
+ // Check close button
+ if (Math.abs(shopPos.x - closeShopButton.x) < 80 && Math.abs(shopPos.y - closeShopButton.y) < 32) {
+ 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) < 100 && Math.abs(bodyPos.y - button.y) < 40) {
+ 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 costs = [50, 100, 150];
+ var cost = costs[upgradeIndex];
+ if (playerCoins >= cost) {
+ playerCoins -= cost;
+ coinText.setText('Coins: ' + playerCoins);
+ switch (upgradeIndex) {
+ case 0:
+ // Health upgrade
+ player.maxHealth += 20;
+ player.health = player.maxHealth;
+ break;
+ case 1:
+ // Damage upgrade
+ player.damage += 10;
+ break;
+ case 2:
+ // Speed upgrade
+ player.speed += 1;
+ break;
+ }
+ }
+}
+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);
+ // Check if all enemies are defeated
+ if (gameState === 'playing' && enemies.length === 0 && !currentBoss) {
+ if (currentLevel % 10 === 0) {
+ // Boss level
+ spawnBoss();
+ } else if (currentLevel % 5 === 0) {
+ // Shop level
+ showShop();
+ } else {
+ // Next level
+ currentLevel++;
+ levelText.setText('Level: ' + currentLevel);
+ enemiesKilled = 0;
+ spawnEnemies();
+ }
+ }
+};
\ No newline at end of file
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