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 }, deer: { asset: 'deer', price: 25, speed: 1.5, health: 2 }, bear: { asset: 'bear', price: 100, speed: 1, health: 5 }, lion: { asset: 'lion', price: 150, speed: 2, health: 4 }, elephant: { asset: 'elephant', price: 200, speed: 0.5, health: 8 }, rhino: { asset: 'rhino', price: 180, speed: 1, health: 6 }, zebra: { asset: 'zebra', price: 60, speed: 3, health: 2 }, giraffe: { asset: 'giraffe', price: 120, speed: 1, health: 3 }, hippo: { asset: 'hippo', price: 90, speed: 0.8, health: 5 }, crocodile: { asset: 'crocodile', price: 80, speed: 1.2, health: 3 }, cheetah: { asset: 'cheetah', price: 140, speed: 6, health: 2 }, cat: { asset: 'cat', price: 300, speed: 1.5, health: 1, evasive: true } }; 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) { 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; } } if (closestBullet) { // 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; // Accelerate when evading tween(self, { speed: self.data.speed * 4 }, { duration: 500, onFinish: function onFinish() { self.speed = self.data.speed; } }); } } 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 = 12; 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; var bullets = []; var animals = []; var money = 0; var totalKills = storage.totalKills || 0; var huntedAnimals = []; // Array to store hunted animals before selling var animalTypes = ['rabbit', 'deer', 'bear', 'lion', 'elephant', 'rhino', 'zebra', 'giraffe', 'hippo', 'crocodile', 'cheetah', 'cat']; // 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); // Shop button var shopBtn = new Text2('SHOP', { size: 50, fill: 0x00FFFF }); shopBtn.anchor.set(0.5, 1); shopBtn.y = -200; // Position above sell button LK.gui.bottom.addChild(shopBtn); // Shop state var shopOpen = false; var shopContainer = null; // Weapon definitions var weaponData = [{ name: 'Basic Rifle', damage: 1, reloadTime: 12, price: 0 }, { name: 'Hunting Rifle', damage: 2, reloadTime: 20, price: 200 }, { name: 'Sniper Rifle', damage: 3, reloadTime: 15, price: 500 }, { name: 'Auto Rifle', damage: 2, reloadTime: 10, price: 800 }, { name: 'Power Rifle', damage: 4, reloadTime: 20, price: 1200 }]; function updateUI() { moneyTxt.setText('$' + money); killsTxt.setText('Kills: ' + totalKills); weaponTxt.setText('Weapon: ' + weaponData[hunter.weapon - 1].name); inventoryTxt.setText('Inventory: ' + huntedAnimals.length); // 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; } } function openShop() { shopOpen = true; // Create shop container shopContainer = new Container(); game.addChild(shopContainer); // Shop background var shopBg = LK.getAsset('crocodile', { scaleX: 15, scaleY: 40, x: 1024, y: 1366, anchorX: 0.5, anchorY: 0.5 }); shopBg.tint = 0x000000; shopBg.alpha = 0.8; shopContainer.addChild(shopBg); // Shop title var shopTitle = new Text2('WEAPON SHOP', { size: 80, fill: 0xFFFFFF }); shopTitle.anchor.set(0.5, 0.5); shopTitle.x = 1024; shopTitle.y = 600; shopContainer.addChild(shopTitle); // Close button var closeBtn = new Text2('CLOSE', { size: 60, fill: 0xFF0000 }); closeBtn.anchor.set(0.5, 0.5); closeBtn.x = 1024; closeBtn.y = 2100; shopContainer.addChild(closeBtn); // Weapon buttons for (var i = 0; i < weaponData.length; i++) { var weapon = weaponData[i]; var yPos = 800 + i * 200; // Weapon name and stats var weaponText = weapon.name + ' - Damage: ' + weapon.damage + ' - Reload: ' + weapon.reloadTime; if (weapon.price > 0) { weaponText += ' - $' + weapon.price; } var weaponBtn = new Text2(weaponText, { size: 40, fill: hunter.weapon === i + 1 ? 0x00FF00 : money >= weapon.price ? 0xFFFFFF : 0x666666 }); weaponBtn.anchor.set(0.5, 0.5); weaponBtn.x = 1024; weaponBtn.y = yPos; weaponBtn.weaponIndex = i + 1; shopContainer.addChild(weaponBtn); } } function closeShop() { shopOpen = false; if (shopContainer) { shopContainer.destroy(); shopContainer = null; } } function buyWeapon(weaponIndex) { var weapon = weaponData[weaponIndex - 1]; if (weaponIndex === hunter.weapon) { // Already owned return; } if (money >= weapon.price) { money -= weapon.price; hunter.weapon = weaponIndex; hunter.maxReloadTime = weapon.reloadTime; updateUI(); storage.money = money; LK.effects.flashScreen(0x00FF00, 300); closeShop(); } } 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 animalType = animalTypes[Math.floor(Math.random() * animalTypes.length)]; 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) { // Handle shop interactions first if (shopOpen) { // Close button if (y > 2050 && y < 2150 && x > 900 && x < 1150) { closeShop(); return; } // Weapon buttons for (var i = 0; i < weaponData.length; i++) { var buttonY = 800 + i * 200; if (y > buttonY - 50 && y < buttonY + 50 && x > 400 && x < 1650) { buyWeapon(i + 1); return; } } return; // Don't process other clicks when shop is open } // 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 shop button above sell button if (y > 2380 && y < 2480 && x > 800 && x < 1248) { // Shop button area openShop(); 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 = weaponData[hunter.weapon - 1].damage; 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
@@ -172,9 +172,9 @@
});
self.aimAngle = 0;
self.weapon = 1;
self.reloadTime = 0;
- self.maxReloadTime = 20;
+ self.maxReloadTime = 12;
self.update = function () {
if (self.reloadTime > 0) {
self.reloadTime--;
}
@@ -265,9 +265,9 @@
// Weapon definitions
var weaponData = [{
name: 'Basic Rifle',
damage: 1,
- reloadTime: 20,
+ reloadTime: 12,
price: 0
}, {
name: 'Hunting Rifle',
damage: 2,
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