User prompt
| Animal | Price | Chance | |--------|-------|---------| | **Rabbit** | $10 | 85% | | **Deer** | $23 | 75% | | **Bear** | $62 | 30% | | **Lion** | $180 | 0.7% | | **Elephant** | $250 | 0.5% | | **Rhino** | $84 | 20% | | **Zebra** | $62 | 60% | | **Giraffe** | $73 | 23% | | **Hippo** | $90 | 17% | | **Crocodile** | $80 | 45% | | **Cheetah** | $50 | 10% | | **Cat** | $60 | 10% | | **Trex** | $215 | 0.5% | | **Dragon** | $300 | 0.05% |
User prompt
Add a chance of occurrence to each animal (example 75%)
User prompt
You became the first reload 25
User prompt
Ok then make it the first 26 Every time we upgrade, our reload will decrease by 2 and every 4 upgrades, our damage will increase by 1.
User prompt
First, set our reload to 8
User prompt
First, let's set our reload to 12.
User prompt
Only in the 3rd upgrade, our damage increases by 1 then increase it by 2 in the 6th upgrade
User prompt
When we start the game, let's say our weapon's damage is 1 and its reload is 15.
User prompt
Every time we upgrade, our reload will increase by 4, and when we start the game, our weapon's reload will be 15 and its damage will be 1. DO THIS NOW
User prompt
Every time we upgrade, our reload will increase by 4, and when we start the game, our weapon's reload will be 15 and its damage will be 1.
User prompt
AND LET OUR GUN'S RELOAD INCREASE WITH EVERY TIME WE BUY UPGRADE AND LET'S SEE OUR RELOAD SPEED AND DAMAGE IN THE LOWER LEFT CORNER
User prompt
REMOVE THE SHOP AND HAVE AN UPGRADE BUTTON AND THE PRICE SHOULD BE 500AND EVERY TIME WE BUY IT, IT WILL INCREASE BY 250 AND GO 15 TIMES
User prompt
AND EVERY TIME WE BUY IT, IT WILL INCREASE BY 250 AND GO 15 TIMES
User prompt
Remove the shop and add a upgrade button. Let the upgrade be $500. Each time we buy it, it will increase by $275 and increase the reload of our weapon. This upgrade will last forever. Every time we buy an upgrade, our reload will increase by 5 and every 3 upgrades, our damage will increase by 1. and let's see our reload and damage in the lower left corner of the screen ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add background to weapon shop
User prompt
Set the reload offirst weapon to 32
Code edit (1 edits merged)
Please save this source code
User prompt
Set the first weapon's reload to 13
User prompt
When the bullet approaches the cat, increase your speed, but when the bullet leaves, return to normal speed.
User prompt
Set the reload of your first weapon to 30
User prompt
When we first start the game, hippo, elephant, giraffe and lion do not come, they start coming when we kill more than 8 animals
User prompt
Let the first weapon have a reload of 12
User prompt
Reduce first weapon reload by 5
User prompt
In the game, there should be no winning, when you do something, there should be no winning, delete winning from the game.
User prompt
Reduce all weapon reload by 5
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Animal = Container.expand(function (animalType) { var self = Container.call(this); var animalData = { rabbit: { asset: 'rabbit', price: 10, speed: 2, health: 1, chance: 0.85 }, deer: { asset: 'deer', price: 23, speed: 1.5, health: 2, chance: 0.75 }, bear: { asset: 'bear', price: 62, speed: 1, health: 5, chance: 0.30 }, lion: { asset: 'lion', price: 180, speed: 2, health: 4, chance: 0.007 }, elephant: { asset: 'elephant', price: 250, speed: 0.5, health: 8, chance: 0.005 }, rhino: { asset: 'rhino', price: 84, speed: 1, health: 6, chance: 0.20 }, zebra: { asset: 'zebra', price: 62, speed: 3, health: 2, chance: 0.60 }, giraffe: { asset: 'giraffe', price: 73, speed: 1, health: 3, chance: 0.23 }, hippo: { asset: 'hippo', price: 90, speed: 0.8, health: 5, chance: 0.17 }, crocodile: { asset: 'crocodile', price: 80, speed: 1.2, health: 3, chance: 0.45 }, cheetah: { asset: 'cheetah', price: 50, speed: 6, health: 2, chance: 0.10 }, cat: { asset: 'cat', price: 60, speed: 1.5, health: 1, evasive: true, chance: 0.10 }, trex: { asset: 'trex', price: 215, speed: 1.5, health: 10, chance: 0.005 }, dragon: { asset: 'dragon', price: 300, speed: 2, health: 15, chance: 0.0005 } }; self.type = animalType; self.data = animalData[animalType]; self.health = self.data.health; self.maxHealth = self.data.health; self.angle = Math.random() * Math.PI * 2; self.speed = self.data.speed; var animalGraphics = self.attachAsset(self.data.asset, { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Cat evasion behavior if (self.data.evasive && bullets) { // Initialize tracking variables if not set if (self.lastClosestDistance === undefined) { self.lastClosestDistance = 999; } if (self.wasNearBullet === undefined) { self.wasNearBullet = false; } var closestBullet = null; var closestDistance = 150; // Detection range for (var b = 0; b < bullets.length; b++) { var bullet = bullets[b]; var dx = bullet.x - self.x; var dy = bullet.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < closestDistance) { closestBullet = bullet; closestDistance = distance; } } var isNearBullet = closestBullet !== null; // Check if bullet is approaching (getting closer) if (isNearBullet && !self.wasNearBullet) { // Bullet just entered detection range - increase speed self.speed = self.data.speed * 4; // Calculate escape direction (opposite to bullet direction) var bulletDx = closestBullet.velocityX; var bulletDy = closestBullet.velocityY; self.angle = Math.atan2(-bulletDy, -bulletDx) + (Math.random() - 0.5) * 0.5; } else if (!isNearBullet && self.wasNearBullet) { // Bullet left detection range - return to normal speed self.speed = self.data.speed; } else if (isNearBullet && closestDistance < self.lastClosestDistance) { // Bullet is still approaching and getting closer - maintain high speed and update direction self.speed = self.data.speed * 4; var bulletDx = closestBullet.velocityX; var bulletDy = closestBullet.velocityY; self.angle = Math.atan2(-bulletDy, -bulletDx) + (Math.random() - 0.5) * 0.5; } // Update tracking variables self.wasNearBullet = isNearBullet; self.lastClosestDistance = isNearBullet ? closestDistance : 999; } self.x += Math.cos(self.angle) * self.speed; self.y += Math.sin(self.angle) * self.speed; // Change direction randomly if (Math.random() < 0.02) { self.angle = Math.random() * Math.PI * 2; } // Keep animals within bounds if (self.x < 100) { self.angle = Math.random() * Math.PI - Math.PI / 2; } if (self.x > 1948) { self.angle = Math.random() * Math.PI + Math.PI / 2; } if (self.y < 100) { self.angle = Math.random() * Math.PI; } if (self.y > 2632) { self.angle = Math.random() * Math.PI + Math.PI; } animalGraphics.rotation = self.angle; }; self.takeDamage = function (damage) { damage = damage || 1; self.health -= damage; if (self.health <= 0) { return true; } return false; }; return self; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.angle = 0; self.velocityX = 0; self.velocityY = 0; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; }; return self; }); var Hunter = Container.expand(function () { var self = Container.call(this); var hunterGraphics = self.attachAsset('hunter', { anchorX: 0.5, anchorY: 0.5 }); self.aimAngle = 0; self.weapon = 1; self.reloadTime = 0; self.maxReloadTime = 25; // Set initial reload time to 25 self.update = function () { if (self.reloadTime > 0) { self.reloadTime--; } hunterGraphics.rotation = self.aimAngle; }; self.canShoot = function () { return self.reloadTime <= 0; }; self.shoot = function () { if (self.canShoot()) { self.reloadTime = self.maxReloadTime; return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 }); /**** * Game Code ****/ // Play background music LK.playMusic('bgmusic'); var hunter = game.addChild(new Hunter()); hunter.x = 2048 / 2; hunter.y = 2732 / 2; hunter.weapon = 1; hunter.maxReloadTime = 25; // Set initial reload time to 25 var bullets = []; var animals = []; var money = storage.money || 0; var totalKills = storage.totalKills || 0; upgradeCount = storage.upgradeCount || 0; var huntedAnimals = []; // Array to store hunted animals before selling var basicAnimalTypes = ['rabbit', 'deer', 'bear', 'rhino', 'zebra', 'crocodile', 'cheetah', 'cat']; var advancedAnimalTypes = ['rabbit', 'deer', 'bear', 'lion', 'elephant', 'rhino', 'zebra', 'giraffe', 'hippo', 'crocodile', 'cheetah', 'cat', 'trex', 'dragon']; // UI Elements - Money Counter var moneyTxt = new Text2('$' + money, { size: 80, fill: 0xFFD700 }); moneyTxt.anchor.set(0.5, 0); LK.gui.top.addChild(moneyTxt); var killsTxt = new Text2('Kills: ' + totalKills, { size: 60, fill: 0xFFFFFF }); killsTxt.anchor.set(0, 0); killsTxt.y = 70; LK.gui.topRight.addChild(killsTxt); var weaponTxt = new Text2('Weapon: Level ' + hunter.weapon, { size: 50, fill: 0xFFFFFF }); weaponTxt.anchor.set(0, 0); weaponTxt.y = 140; LK.gui.topRight.addChild(weaponTxt); // Inventory counter var inventoryTxt = new Text2('Inventory: 0', { size: 40, fill: 0x00FF00 }); inventoryTxt.anchor.set(0, 0); inventoryTxt.y = 200; LK.gui.topRight.addChild(inventoryTxt); // Sell button var sellBtn = new Text2('SELL ALL', { size: 50, fill: 0x00FF00 }); sellBtn.anchor.set(0.5, 1); sellBtn.y = -100; // Move button 100 pixels higher LK.gui.bottom.addChild(sellBtn); // Upgrade button var upgradeBtn = new Text2('UPGRADE', { size: 50, fill: 0x00FFFF }); upgradeBtn.anchor.set(0.5, 1); upgradeBtn.y = -200; // Position above sell button LK.gui.bottom.addChild(upgradeBtn); // Upgrade tracking var upgradeCount = 0; var maxUpgrades = 26; // Stats display in lower left corner var statsContainer = new Container(); LK.gui.bottomLeft.addChild(statsContainer); var damageTxt = new Text2('Damage: ' + getCurrentDamage(), { size: 40, fill: 0xFFFFFF }); damageTxt.anchor.set(0, 1); damageTxt.y = -50; statsContainer.addChild(damageTxt); var reloadTxt = new Text2('Reload: ' + getCurrentReloadTime(), { size: 40, fill: 0xFFFFFF }); reloadTxt.anchor.set(0, 1); reloadTxt.y = -10; statsContainer.addChild(reloadTxt); // Upgrade system var baseDamage = 1; var baseReloadTime = 25; function getUpgradePrice() { if (upgradeCount >= maxUpgrades) { return 500 + 250 * maxUpgrades; // Cap at 15 upgrades } return 500 + upgradeCount * 250; } function getCurrentDamage() { var damage = baseDamage; damage += Math.floor(upgradeCount / 4); // Increase damage by 1 every 4 upgrades return damage; } function getCurrentReloadTime() { return baseReloadTime - upgradeCount * 2; // Reload time decreases by 2 for each upgrade } function updateUI() { moneyTxt.setText('$' + money); killsTxt.setText('Kills: ' + totalKills); weaponTxt.setText('Damage: ' + getCurrentDamage() + ' | Reload: ' + getCurrentReloadTime()); inventoryTxt.setText('Inventory: ' + huntedAnimals.length); // Update stats display damageTxt.setText('Damage: ' + getCurrentDamage()); reloadTxt.setText('Reload: ' + getCurrentReloadTime()); // Update sell button to show potential earnings var totalValue = 0; for (var i = 0; i < huntedAnimals.length; i++) { totalValue += huntedAnimals[i].price; } if (huntedAnimals.length > 0) { sellBtn.setText('SELL ALL ($' + totalValue + ')'); sellBtn.fill = 0x00FF00; } else { sellBtn.setText('SELL ALL'); sellBtn.fill = 0x666666; } // Update upgrade button var upgradePrice = getUpgradePrice(); if (upgradeCount >= maxUpgrades) { upgradeBtn.setText('UPGRADE (MAX)'); upgradeBtn.fill = 0x666666; } else if (money >= upgradePrice) { upgradeBtn.setText('UPGRADE ($' + upgradePrice + ')'); upgradeBtn.fill = 0x00FFFF; } else { upgradeBtn.setText('UPGRADE ($' + upgradePrice + ')'); upgradeBtn.fill = 0x666666; } } function buyUpgrade() { var upgradePrice = getUpgradePrice(); // Check if max upgrades reached if (upgradeCount >= maxUpgrades) { return; } if (money >= upgradePrice) { money -= upgradePrice; upgradeCount++; hunter.maxReloadTime = getCurrentReloadTime(); updateUI(); storage.money = money; storage.upgradeCount = upgradeCount; LK.effects.flashScreen(0x00FF00, 300); } } function sellAllAnimals() { var totalValue = 0; for (var i = 0; i < huntedAnimals.length; i++) { totalValue += huntedAnimals[i].price; } money += totalValue; huntedAnimals = []; updateUI(); storage.money = money; if (totalValue > 0) { LK.effects.flashScreen(0x00FF00, 300); } } function spawnAnimal() { var currentAnimalTypes = totalKills > 8 ? advancedAnimalTypes : basicAnimalTypes; var animalType = null; var attempts = 0; var maxAttempts = 50; // Keep trying to spawn an animal based on chance until successful or max attempts reached while (animalType === null && attempts < maxAttempts) { var randomType = currentAnimalTypes[Math.floor(Math.random() * currentAnimalTypes.length)]; var tempAnimal = new Animal(randomType); var chance = tempAnimal.data.chance || 1.0; // Default to 100% if no chance specified if (Math.random() < chance) { animalType = randomType; } else { tempAnimal.destroy(); // Clean up the temporary animal if not spawned } attempts++; } // If we couldn't spawn anything after max attempts, force spawn a common animal if (animalType === null) { animalType = 'rabbit'; // Fallback to rabbit as it has high chance } var animal = new Animal(animalType); // Spawn at edge of screen var side = Math.floor(Math.random() * 4); switch (side) { case 0: // Top animal.x = Math.random() * 2048; animal.y = 0; break; case 1: // Right animal.x = 2048; animal.y = Math.random() * 2732; break; case 2: // Bottom animal.x = Math.random() * 2048; animal.y = 2732; break; case 3: // Left animal.x = 0; animal.y = Math.random() * 2732; break; } animals.push(animal); game.addChild(animal); } function shootBullet(targetX, targetY) { if (hunter.shoot()) { var bullet = new Bullet(); bullet.x = hunter.x; bullet.y = hunter.y; var dx = targetX - hunter.x; var dy = targetY - hunter.y; var distance = Math.sqrt(dx * dx + dy * dy); bullet.velocityX = dx / distance * bullet.speed; bullet.velocityY = dy / distance * bullet.speed; bullet.angle = Math.atan2(dy, dx); bullets.push(bullet); game.addChild(bullet); LK.getSound('shoot').play(); } } game.down = function (x, y, obj) { // Check if clicking sell button at bottom of screen (moved 100px higher) - larger hitbox for mobile if (y > 2480 && y < 2620 && x > 800 && x < 1248) { // Bottom area, centered button with expanded touch area if (huntedAnimals.length > 0) { sellAllAnimals(); LK.effects.flashObject(sellBtn, 0xFFFFFF, 200); } return; } // Check if clicking upgrade button above sell button if (y > 2380 && y < 2480 && x > 800 && x < 1248) { // Upgrade button area buyUpgrade(); LK.effects.flashObject(upgradeBtn, 0xFFFFFF, 200); return; } // Aim and shoot at clicked location - use x,y directly as they are already in game coordinates var dx = x - hunter.x; var dy = y - hunter.y; hunter.aimAngle = Math.atan2(dy, dx); shootBullet(x, y); }; game.update = function () { // Spawn animals if (LK.ticks % 120 == 0) { spawnAnimal(); } // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; // Remove off-screen bullets if (bullet.x < -50 || bullet.x > 2098 || bullet.y < -50 || bullet.y > 2782) { bullet.destroy(); bullets.splice(i, 1); continue; } // Check bullet-animal collisions for (var j = animals.length - 1; j >= 0; j--) { var animal = animals[j]; if (bullet.intersects(animal)) { var weaponDamage = getCurrentDamage(); if (animal.takeDamage(weaponDamage)) { // Animal killed - add to inventory with complete pricing data huntedAnimals.push({ type: animal.type, price: animal.data.price, asset: animal.data.asset }); totalKills++; LK.getSound('hit').play(); LK.effects.flashObject(animal, 0xFF0000, 200); animal.destroy(); animals.splice(j, 1); updateUI(); storage.totalKills = totalKills; } bullet.destroy(); bullets.splice(i, 1); break; } } } // Remove animals that are too far off screen for (var k = animals.length - 1; k >= 0; k--) { var animal = animals[k]; if (animal.x < -200 || animal.x > 2248 || animal.y < -200 || animal.y > 2932) { animal.destroy(); animals.splice(k, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -18,61 +18,61 @@
chance: 0.85
},
deer: {
asset: 'deer',
- price: 25,
+ price: 23,
speed: 1.5,
health: 2,
chance: 0.75
},
bear: {
asset: 'bear',
- price: 100,
+ price: 62,
speed: 1,
health: 5,
chance: 0.30
},
lion: {
asset: 'lion',
- price: 150,
+ price: 180,
speed: 2,
health: 4,
- chance: 0.25
+ chance: 0.007
},
elephant: {
asset: 'elephant',
- price: 200,
+ price: 250,
speed: 0.5,
health: 8,
- chance: 0.20
+ chance: 0.005
},
rhino: {
asset: 'rhino',
- price: 180,
+ price: 84,
speed: 1,
health: 6,
- chance: 0.25
+ chance: 0.20
},
zebra: {
asset: 'zebra',
- price: 60,
+ price: 62,
speed: 3,
health: 2,
chance: 0.60
},
giraffe: {
asset: 'giraffe',
- price: 120,
+ price: 73,
speed: 1,
health: 3,
- chance: 0.40
+ chance: 0.23
},
hippo: {
asset: 'hippo',
price: 90,
speed: 0.8,
health: 5,
- chance: 0.35
+ chance: 0.17
},
crocodile: {
asset: 'crocodile',
price: 80,
@@ -81,20 +81,34 @@
chance: 0.45
},
cheetah: {
asset: 'cheetah',
- price: 140,
+ price: 50,
speed: 6,
health: 2,
- chance: 0.30
+ chance: 0.10
},
cat: {
asset: 'cat',
- price: 120,
+ price: 60,
speed: 1.5,
health: 1,
evasive: true,
- chance: 0.50
+ chance: 0.10
+ },
+ trex: {
+ asset: 'trex',
+ price: 215,
+ speed: 1.5,
+ health: 10,
+ chance: 0.005
+ },
+ dragon: {
+ asset: 'dragon',
+ price: 300,
+ speed: 2,
+ health: 15,
+ chance: 0.0005
}
};
self.type = animalType;
self.data = animalData[animalType];
@@ -250,9 +264,9 @@
var totalKills = storage.totalKills || 0;
upgradeCount = storage.upgradeCount || 0;
var huntedAnimals = []; // Array to store hunted animals before selling
var basicAnimalTypes = ['rabbit', 'deer', 'bear', 'rhino', 'zebra', 'crocodile', 'cheetah', 'cat'];
-var advancedAnimalTypes = ['rabbit', 'deer', 'bear', 'lion', 'elephant', 'rhino', 'zebra', 'giraffe', 'hippo', 'crocodile', 'cheetah', 'cat'];
+var advancedAnimalTypes = ['rabbit', 'deer', 'bear', 'lion', 'elephant', 'rhino', 'zebra', 'giraffe', 'hippo', 'crocodile', 'cheetah', 'cat', 'trex', 'dragon'];
// UI Elements - Money Counter
var moneyTxt = new Text2('$' + money, {
size: 80,
fill: 0xFFD700
Hunter pixel. In-Game asset. 2d. High contrast. No shadows
Pixel bear. In-Game asset. 2d. High contrast. No shadows
Pixel deer. In-Game asset. 2d. High contrast. No shadows
Pixel Cheetah. In-Game asset. 2d. High contrast. No shadows
Pixel Rabbit. In-Game asset. 2d. High contrast. No shadows
Pixel cat. In-Game asset. 2d. High contrast. No shadows
elephant pixel. In-Game asset. 2d. High contrast. No shadows
Hippo pixel. In-Game asset. 2d. High contrast. No shadows
Pixel lion. In-Game asset. 2d. High contrast. No shadows
Pixel rhino. In-Game asset. 2d. High contrast. No shadows
Giraffe Pixel. In-Game asset. 2d. High contrast. No shadows
Crocodile pixel. In-Game asset. 2d. High contrast. No shadows
Zebra pixel. In-Game asset. 2d. High contrast. No shadows
T rex 8bit. In-Game asset. 2d. High contrast. No shadows
Dragon 8 bit. In-Game asset. 2d. High contrast. No shadows