User prompt
puedes hacer que cuando la hormiga haga daño no se mueva osea no se tenga que acercar demasiado a el rival es que esta medio dificil
User prompt
cuando la hormiga/nosotros llegue a la mitad de camino para ganar con algunos compañeros hormigas y todos tienen armas mas avanzadas que nosotros ósea la hormiga tengas que pelear contra algunos insectos muy fuertes para defender el hormiguero
User prompt
puedes añadir antes de cada partida elegir dificultad normal y dificil
User prompt
agrega que podamos dañar a los enemigos con la arma que crafteamos
User prompt
que hayan diferentes climas como lluvia acida.piedras que caen del cielo y truenos y tambien que se pueda entrar a el hormiguero y hacer algunas armas por ejemplo un hacha una espada y algunas cosas mas que se te suceden. no me gusto tanto la parte del tiempo la puedes quitar y en vez de eso poner una barra de vida y que encuentren unos insectos mas que te puedan atacar y si no tienes vida mueres
Code edit (1 edits merged)
Please save this source code
User prompt
Ant Colony Survival Quest
Initial prompt
hola un juego sobre una hormiga que tiene que encontrar materiales para sobrevivir en su hormiguero la hormiga tiene que explorar muchos lugares para que todo el hormiguero pueda sobrevivir
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Ant = Container.expand(function () { var self = Container.call(this); var antGraphics = self.attachAsset('ant', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; self.speed = 3; self.isMoving = false; self.targetX = 0; self.targetY = 0; self.weapon = null; self.attackDamage = 10; self.moveTo = function (x, y) { self.targetX = x; self.targetY = y; self.isMoving = true; }; self.takeDamage = function (damage) { self.health = Math.max(0, self.health - damage); LK.effects.flashObject(self, 0xFF0000, 300); }; self.equipWeapon = function (weaponType) { self.weapon = weaponType; if (weaponType === 'sword') self.attackDamage = 25;else if (weaponType === 'axe') self.attackDamage = 20;else self.attackDamage = 10; }; self.update = function () { if (self.isMoving) { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > self.speed) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } else { self.x = self.targetX; self.y = self.targetY; self.isMoving = false; } } }; return self; }); var Beetle = Container.expand(function () { var self = Container.call(this); var beetleGraphics = self.attachAsset('beetle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0.8; self.direction = Math.random() * Math.PI * 2; self.changeDirectionTimer = 0; self.attackDamage = 20; self.health = 50; self.lastAttackTime = 0; self.update = function () { self.changeDirectionTimer++; if (self.changeDirectionTimer > 150) { self.direction = Math.random() * Math.PI * 2; self.changeDirectionTimer = 0; } self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; // Keep within bounds if (self.x < 50) self.x = 50; if (self.x > 1998) self.x = 1998; if (self.y < 50) self.y = 50; if (self.y > 2682) self.y = 2682; }; return self; }); var Predator = Container.expand(function () { var self = Container.call(this); var predatorGraphics = self.attachAsset('predator', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.direction = Math.random() * Math.PI * 2; self.changeDirectionTimer = 0; self.update = function () { self.changeDirectionTimer++; if (self.changeDirectionTimer > 120) { self.direction = Math.random() * Math.PI * 2; self.changeDirectionTimer = 0; } self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; // Keep predator within game bounds if (self.x < 50) self.x = 50; if (self.x > 1998) self.x = 1998; if (self.y < 50) self.y = 50; if (self.y > 2682) self.y = 2682; }; return self; }); var Resource = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.value = 1; var assetName = 'foodCrumb'; if (type === 'twig') assetName = 'twig';else if (type === 'leaf') assetName = 'leaf';else if (type === 'water') assetName = 'waterDrop'; var resourceGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); if (type === 'twig') self.value = 2;else if (type === 'leaf') self.value = 3;else if (type === 'water') self.value = 5; return self; }); var Spider = Container.expand(function () { var self = Container.call(this); var spiderGraphics = self.attachAsset('spider', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1.5; self.direction = Math.random() * Math.PI * 2; self.changeDirectionTimer = 0; self.attackDamage = 15; self.health = 30; self.lastAttackTime = 0; self.update = function () { self.changeDirectionTimer++; if (self.changeDirectionTimer > 90) { self.direction = Math.random() * Math.PI * 2; self.changeDirectionTimer = 0; } self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; // Keep within bounds if (self.x < 50) self.x = 50; if (self.x > 1998) self.x = 1998; if (self.y < 50) self.y = 50; if (self.y > 2682) self.y = 2682; }; return self; }); var Weapon = Container.expand(function (type) { var self = Container.call(this); self.type = type; var weaponGraphics = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); return self; }); var WeatherEvent = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.damage = 0; if (type === 'acidRain') { var rainGraphics = self.attachAsset('acidRain', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.damage = 10; } else if (type === 'stone') { var stoneGraphics = self.attachAsset('fallingStone', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6; self.damage = 25; } else if (type === 'lightning') { var lightningGraphics = self.attachAsset('lightning', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.damage = 30; self.lifeTime = 30; } self.update = function () { if (self.type !== 'lightning') { self.y += self.speed; } else { self.lifeTime--; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x90EE90 }); /**** * Game Code ****/ // Weather assets // Weapon assets // Health bar assets // New insect enemies // Anthill interior var ant; var anthill; var resources = []; var predators = []; var spiders = []; var beetles = []; var weatherEvents = []; var weapons = []; var colonyStrength = 0; var maxColonyStrength = 100; var gamePhase = 'selection'; // 'selection', 'exploration', 'anthill' var isInsideAnthill = false; var craftingTable; var anthillInterior; var difficulty = 'normal'; // 'normal' or 'hard' var difficultySelected = false; var normalButton; var hardButton; var difficultyTitle; // UI Elements var healthBarBg; var healthBar; var strengthText; var resourceCountText; var weaponText; var collectedResources = 0; var weatherTimer = 0; var currentWeather = 'clear'; // Initialize anthill (hidden initially) anthill = game.addChild(LK.getAsset('anthill', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 2400 })); anthill.visible = false; // Initialize ant (hidden initially) ant = game.addChild(new Ant()); ant.x = anthill.x; ant.y = anthill.y - 100; ant.visible = false; // Initialize difficulty selection UI difficultyTitle = new Text2('Selecciona Dificultad', { size: 80, fill: 0xFFFFFF }); difficultyTitle.anchor.set(0.5, 0.5); difficultyTitle.x = 1024; difficultyTitle.y = 800; game.addChild(difficultyTitle); normalButton = LK.getAsset('healthBackground', { anchorX: 0.5, anchorY: 0.5, x: 724, y: 1200, scaleX: 2, scaleY: 3 }); game.addChild(normalButton); var normalText = new Text2('NORMAL', { size: 60, fill: 0x00FF00 }); normalText.anchor.set(0.5, 0.5); normalText.x = 724; normalText.y = 1200; game.addChild(normalText); hardButton = LK.getAsset('healthBackground', { anchorX: 0.5, anchorY: 0.5, x: 1324, y: 1200, scaleX: 2, scaleY: 3 }); game.addChild(hardButton); var hardText = new Text2('DIFICIL', { size: 60, fill: 0xFF0000 }); hardText.anchor.set(0.5, 0.5); hardText.x = 1324; hardText.y = 1200; game.addChild(hardText); // Initialize UI (hidden initially) healthBarBg = LK.gui.top.addChild(LK.getAsset('healthBackground', { x: 200, y: 100 })); healthBarBg.visible = false; healthBar = LK.gui.top.addChild(LK.getAsset('healthBar', { x: 200, y: 100 })); healthBar.visible = false; strengthText = new Text2('Colony Strength: 0/100', { size: 40, fill: 0xFFFFFF }); strengthText.anchor.set(0, 0); strengthText.x = 50; strengthText.y = 150; strengthText.visible = false; LK.gui.top.addChild(strengthText); resourceCountText = new Text2('Resources: 0', { size: 40, fill: 0xFFFFFF }); resourceCountText.anchor.set(0, 0); resourceCountText.x = 50; resourceCountText.y = 200; resourceCountText.visible = false; LK.gui.top.addChild(resourceCountText); weaponText = new Text2('Weapon: None', { size: 40, fill: 0xFFFFFF }); weaponText.anchor.set(0, 0); weaponText.x = 50; weaponText.y = 250; weaponText.visible = false; LK.gui.top.addChild(weaponText); // Spawn initial resources function spawnResource() { var types = ['food', 'twig', 'leaf', 'water']; var randomType = types[Math.floor(Math.random() * types.length)]; var resource = game.addChild(new Resource(randomType)); resource.x = Math.random() * 1800 + 124; resource.y = Math.random() * 2000 + 200; // Avoid spawning too close to anthill var distanceToAnthill = Math.sqrt(Math.pow(resource.x - anthill.x, 2) + Math.pow(resource.y - anthill.y, 2)); if (distanceToAnthill < 300) { resource.x = Math.random() * 1000 + 100; resource.y = Math.random() * 1500 + 200; } resources.push(resource); } // Spawn initial predators function spawnPredator() { var predator = game.addChild(new Predator()); predator.x = Math.random() * 1800 + 124; predator.y = Math.random() * 1800 + 200; predators.push(predator); } function spawnSpider() { var spider = game.addChild(new Spider()); spider.x = Math.random() * 1800 + 124; spider.y = Math.random() * 1800 + 200; spiders.push(spider); } function spawnBeetle() { var beetle = game.addChild(new Beetle()); beetle.x = Math.random() * 1800 + 124; beetle.y = Math.random() * 1800 + 200; beetles.push(beetle); } function spawnWeatherEvent() { var types = ['acidRain', 'stone', 'lightning']; var randomType = types[Math.floor(Math.random() * types.length)]; var weather = game.addChild(new WeatherEvent(randomType)); if (randomType === 'lightning') { weather.x = Math.random() * 1800 + 124; weather.y = 100; LK.getSound('lightning').play(); } else { weather.x = Math.random() * 1800 + 124; weather.y = 0; } weatherEvents.push(weather); } function setupAnthillInterior() { anthillInterior = game.addChild(LK.getAsset('anthillInterior', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 })); anthillInterior.visible = false; craftingTable = game.addChild(LK.getAsset('craftingTable', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1200 })); craftingTable.visible = false; } // Initialize world for (var i = 0; i < 15; i++) { spawnResource(); } for (var i = 0; i < 3; i++) { spawnPredator(); } for (var i = 0; i < 2; i++) { spawnSpider(); } for (var i = 0; i < 2; i++) { spawnBeetle(); } setupAnthillInterior(); function startGame() { gamePhase = 'exploration'; difficultySelected = true; // Hide difficulty selection UI difficultyTitle.destroy(); normalButton.destroy(); hardButton.destroy(); // Show game UI healthBarBg.visible = true; healthBar.visible = true; strengthText.visible = true; resourceCountText.visible = true; weaponText.visible = true; anthill.visible = true; ant.visible = true; // Apply difficulty adjustments if (difficulty === 'hard') { // Hard mode adjustments for (var i = 0; i < 3; i++) { spawnSpider(); } for (var i = 0; i < 3; i++) { spawnBeetle(); } // Reduce ant health in hard mode ant.health = 70; ant.maxHealth = 70; } } // Resource spawn timer var resourceSpawnTimer = 0; game.down = function (x, y, obj) { if (gamePhase === 'selection') { // Check if clicking on normal button var distanceToNormal = Math.sqrt(Math.pow(x - normalButton.x, 2) + Math.pow(y - normalButton.y, 2)); if (distanceToNormal < 150) { difficulty = 'normal'; startGame(); } // Check if clicking on hard button var distanceToHard = Math.sqrt(Math.pow(x - hardButton.x, 2) + Math.pow(y - hardButton.y, 2)); if (distanceToHard < 150) { difficulty = 'hard'; startGame(); } } else if (ant.health > 0) { if (isInsideAnthill) { // Check if clicking on crafting table var distanceToCrafting = Math.sqrt(Math.pow(x - craftingTable.x, 2) + Math.pow(y - craftingTable.y, 2)); if (distanceToCrafting < 100 && collectedResources >= 5) { // Craft weapon var weaponTypes = ['axe', 'sword', 'shield']; var randomWeapon = weaponTypes[Math.floor(Math.random() * weaponTypes.length)]; ant.equipWeapon(randomWeapon); collectedResources -= 5; LK.getSound('craft').play(); } else { ant.moveTo(x, y); } } else { // Check if clicking on anthill to enter var distanceToAnthill = Math.sqrt(Math.pow(x - anthill.x, 2) + Math.pow(y - anthill.y, 2)); if (distanceToAnthill < 100) { isInsideAnthill = true; ant.x = 1024; ant.y = 1500; anthillInterior.visible = true; craftingTable.visible = true; // Hide exterior elements anthill.visible = false; for (var i = 0; i < resources.length; i++) { resources[i].visible = false; } for (var i = 0; i < predators.length; i++) { predators[i].visible = false; } for (var i = 0; i < spiders.length; i++) { spiders[i].visible = false; } for (var i = 0; i < beetles.length; i++) { beetles[i].visible = false; } } else { ant.moveTo(x, y); } } } }; game.update = function () { if (gamePhase === 'selection') { // Don't update game logic during difficulty selection return; } // Update health bar var healthPercent = ant.health / ant.maxHealth; healthBar.scaleX = healthPercent; // Update UI text strengthText.setText('Colony Strength: ' + colonyStrength + '/' + maxColonyStrength); resourceCountText.setText('Resources: ' + collectedResources); weaponText.setText('Weapon: ' + (ant.weapon || 'None')); if (!isInsideAnthill) { // Weather system weatherTimer++; var weatherSpawnRate = difficulty === 'hard' ? 250 : 400; var weatherChance = difficulty === 'hard' ? 0.5 : 0.3; if (weatherTimer > weatherSpawnRate) { if (Math.random() < weatherChance) { spawnWeatherEvent(); } weatherTimer = 0; } // Update weather events for (var i = weatherEvents.length - 1; i >= 0; i--) { var weather = weatherEvents[i]; if (weather.type === 'lightning' && weather.lifeTime <= 0) { weather.destroy(); weatherEvents.splice(i, 1); } else if (weather.y > 2800) { weather.destroy(); weatherEvents.splice(i, 1); } else if (ant.intersects(weather)) { ant.takeDamage(weather.damage); LK.getSound('impact').play(); weather.destroy(); weatherEvents.splice(i, 1); } } // Spawn new resources periodically resourceSpawnTimer++; if (resourceSpawnTimer > 300 && resources.length < 20) { spawnResource(); resourceSpawnTimer = 0; } // Check for resource collection for (var i = resources.length - 1; i >= 0; i--) { var resource = resources[i]; if (ant.intersects(resource) && resource.visible) { LK.getSound('collect').play(); colonyStrength = Math.min(maxColonyStrength, colonyStrength + resource.value); collectedResources++; LK.setScore(LK.getScore() + resource.value * 10); // Flash effect LK.effects.flashObject(ant, 0x00FF00, 300); resource.destroy(); resources.splice(i, 1); } } // Check for predator collisions for (var i = 0; i < predators.length; i++) { var predator = predators[i]; if (ant.intersects(predator) && predator.visible) { LK.getSound('danger').play(); ant.takeDamage(15); // Push ant away from predator var dx = ant.x - predator.x; var dy = ant.y - predator.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { ant.x += dx / distance * 100; ant.y += dy / distance * 100; } } } // Check for spider collisions and combat for (var i = spiders.length - 1; i >= 0; i--) { var spider = spiders[i]; if (ant.intersects(spider) && spider.visible) { if (ant.weapon) { // Attack spider with weapon spider.health -= ant.attackDamage; LK.effects.flashObject(spider, 0xFF0000, 200); if (spider.health <= 0) { // Spider defeated LK.effects.flashObject(ant, 0x00FF00, 300); LK.setScore(LK.getScore() + 50); spider.destroy(); spiders.splice(i, 1); continue; } } LK.getSound('danger').play(); ant.takeDamage(spider.attackDamage); // Push ant away var dx = ant.x - spider.x; var dy = ant.y - spider.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { ant.x += dx / distance * 80; ant.y += dy / distance * 80; } } } // Check for beetle collisions and combat for (var i = beetles.length - 1; i >= 0; i--) { var beetle = beetles[i]; if (ant.intersects(beetle) && beetle.visible) { if (ant.weapon) { // Attack beetle with weapon beetle.health -= ant.attackDamage; LK.effects.flashObject(beetle, 0xFF0000, 200); if (beetle.health <= 0) { // Beetle defeated LK.effects.flashObject(ant, 0x00FF00, 300); LK.setScore(LK.getScore() + 75); beetle.destroy(); beetles.splice(i, 1); continue; } } LK.getSound('danger').play(); ant.takeDamage(beetle.attackDamage); // Push ant away var dx = ant.x - beetle.x; var dy = ant.y - beetle.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { ant.x += dx / distance * 60; ant.y += dy / distance * 60; } } } // Check if ant is at anthill (health restoration) var distanceToAnthill = Math.sqrt(Math.pow(ant.x - anthill.x, 2) + Math.pow(ant.y - anthill.y, 2)); if (distanceToAnthill < 100 && anthill.visible) { // Restore some health when at anthill ant.health = Math.min(ant.maxHealth, ant.health + 0.5); } } else { // Inside anthill logic // Exit anthill if ant moves to bottom if (ant.y > 2000) { isInsideAnthill = false; ant.x = anthill.x; ant.y = anthill.y - 100; anthillInterior.visible = false; craftingTable.visible = false; // Show exterior elements anthill.visible = true; for (var i = 0; i < resources.length; i++) { resources[i].visible = true; } for (var i = 0; i < predators.length; i++) { predators[i].visible = true; } for (var i = 0; i < spiders.length; i++) { spiders[i].visible = true; } for (var i = 0; i < beetles.length; i++) { beetles[i].visible = true; } } } // Game over conditions if (ant.health <= 0) { LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); } // Win condition if (colonyStrength >= maxColonyStrength) { LK.showYouWin(); } };
===================================================================
--- original.js
+++ change.js
@@ -199,13 +199,13 @@
/****
* Game Code
****/
-// Anthill interior
-// New insect enemies
-// Health bar assets
-// Weapon assets
// Weather assets
+// Weapon assets
+// Health bar assets
+// New insect enemies
+// Anthill interior
var ant;
var anthill;
var resources = [];
var predators = [];
@@ -214,12 +214,17 @@
var weatherEvents = [];
var weapons = [];
var colonyStrength = 0;
var maxColonyStrength = 100;
-var gamePhase = 'exploration'; // 'exploration', 'anthill'
+var gamePhase = 'selection'; // 'selection', 'exploration', 'anthill'
var isInsideAnthill = false;
var craftingTable;
var anthillInterior;
+var difficulty = 'normal'; // 'normal' or 'hard'
+var difficultySelected = false;
+var normalButton;
+var hardButton;
+var difficultyTitle;
// UI Elements
var healthBarBg;
var healthBar;
var strengthText;
@@ -227,51 +232,101 @@
var weaponText;
var collectedResources = 0;
var weatherTimer = 0;
var currentWeather = 'clear';
-// Initialize anthill
+// Initialize anthill (hidden initially)
anthill = game.addChild(LK.getAsset('anthill', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2400
}));
-// Initialize ant
+anthill.visible = false;
+// Initialize ant (hidden initially)
ant = game.addChild(new Ant());
ant.x = anthill.x;
ant.y = anthill.y - 100;
-// Initialize UI
+ant.visible = false;
+// Initialize difficulty selection UI
+difficultyTitle = new Text2('Selecciona Dificultad', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+difficultyTitle.anchor.set(0.5, 0.5);
+difficultyTitle.x = 1024;
+difficultyTitle.y = 800;
+game.addChild(difficultyTitle);
+normalButton = LK.getAsset('healthBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 724,
+ y: 1200,
+ scaleX: 2,
+ scaleY: 3
+});
+game.addChild(normalButton);
+var normalText = new Text2('NORMAL', {
+ size: 60,
+ fill: 0x00FF00
+});
+normalText.anchor.set(0.5, 0.5);
+normalText.x = 724;
+normalText.y = 1200;
+game.addChild(normalText);
+hardButton = LK.getAsset('healthBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1324,
+ y: 1200,
+ scaleX: 2,
+ scaleY: 3
+});
+game.addChild(hardButton);
+var hardText = new Text2('DIFICIL', {
+ size: 60,
+ fill: 0xFF0000
+});
+hardText.anchor.set(0.5, 0.5);
+hardText.x = 1324;
+hardText.y = 1200;
+game.addChild(hardText);
+// Initialize UI (hidden initially)
healthBarBg = LK.gui.top.addChild(LK.getAsset('healthBackground', {
x: 200,
y: 100
}));
+healthBarBg.visible = false;
healthBar = LK.gui.top.addChild(LK.getAsset('healthBar', {
x: 200,
y: 100
}));
+healthBar.visible = false;
strengthText = new Text2('Colony Strength: 0/100', {
size: 40,
fill: 0xFFFFFF
});
strengthText.anchor.set(0, 0);
strengthText.x = 50;
strengthText.y = 150;
+strengthText.visible = false;
LK.gui.top.addChild(strengthText);
resourceCountText = new Text2('Resources: 0', {
size: 40,
fill: 0xFFFFFF
});
resourceCountText.anchor.set(0, 0);
resourceCountText.x = 50;
resourceCountText.y = 200;
+resourceCountText.visible = false;
LK.gui.top.addChild(resourceCountText);
weaponText = new Text2('Weapon: None', {
size: 40,
fill: 0xFFFFFF
});
weaponText.anchor.set(0, 0);
weaponText.x = 50;
weaponText.y = 250;
+weaponText.visible = false;
LK.gui.top.addChild(weaponText);
// Spawn initial resources
function spawnResource() {
var types = ['food', 'twig', 'leaf', 'water'];
@@ -349,12 +404,54 @@
for (var i = 0; i < 2; i++) {
spawnBeetle();
}
setupAnthillInterior();
+function startGame() {
+ gamePhase = 'exploration';
+ difficultySelected = true;
+ // Hide difficulty selection UI
+ difficultyTitle.destroy();
+ normalButton.destroy();
+ hardButton.destroy();
+ // Show game UI
+ healthBarBg.visible = true;
+ healthBar.visible = true;
+ strengthText.visible = true;
+ resourceCountText.visible = true;
+ weaponText.visible = true;
+ anthill.visible = true;
+ ant.visible = true;
+ // Apply difficulty adjustments
+ if (difficulty === 'hard') {
+ // Hard mode adjustments
+ for (var i = 0; i < 3; i++) {
+ spawnSpider();
+ }
+ for (var i = 0; i < 3; i++) {
+ spawnBeetle();
+ }
+ // Reduce ant health in hard mode
+ ant.health = 70;
+ ant.maxHealth = 70;
+ }
+}
// Resource spawn timer
var resourceSpawnTimer = 0;
game.down = function (x, y, obj) {
- if (ant.health > 0) {
+ if (gamePhase === 'selection') {
+ // Check if clicking on normal button
+ var distanceToNormal = Math.sqrt(Math.pow(x - normalButton.x, 2) + Math.pow(y - normalButton.y, 2));
+ if (distanceToNormal < 150) {
+ difficulty = 'normal';
+ startGame();
+ }
+ // Check if clicking on hard button
+ var distanceToHard = Math.sqrt(Math.pow(x - hardButton.x, 2) + Math.pow(y - hardButton.y, 2));
+ if (distanceToHard < 150) {
+ difficulty = 'hard';
+ startGame();
+ }
+ } else if (ant.health > 0) {
if (isInsideAnthill) {
// Check if clicking on crafting table
var distanceToCrafting = Math.sqrt(Math.pow(x - craftingTable.x, 2) + Math.pow(y - craftingTable.y, 2));
if (distanceToCrafting < 100 && collectedResources >= 5) {
@@ -396,8 +493,12 @@
}
}
};
game.update = function () {
+ if (gamePhase === 'selection') {
+ // Don't update game logic during difficulty selection
+ return;
+ }
// Update health bar
var healthPercent = ant.health / ant.maxHealth;
healthBar.scaleX = healthPercent;
// Update UI text
@@ -406,10 +507,12 @@
weaponText.setText('Weapon: ' + (ant.weapon || 'None'));
if (!isInsideAnthill) {
// Weather system
weatherTimer++;
- if (weatherTimer > 400) {
- if (Math.random() < 0.3) {
+ var weatherSpawnRate = difficulty === 'hard' ? 250 : 400;
+ var weatherChance = difficulty === 'hard' ? 0.5 : 0.3;
+ if (weatherTimer > weatherSpawnRate) {
+ if (Math.random() < weatherChance) {
spawnWeatherEvent();
}
weatherTimer = 0;
}
escarabajo de terror. In-Game asset. High contrast. No shadows
hormiga. In-Game asset. 2d. High contrast. No shadows
tierra amontonada. In-Game asset. 2d. High contrast
hoja. In-Game asset. 2d. High contrast
escarabajo. In-Game asset. 2d. High contrast. No shadows
hacha. In-Game asset. 2d. High contrast. No shadows
araña miedo. In-Game asset. 2d. High contrast. No shadows
gota de acido. In-Game asset. 2d. High contrast. No shadows
interior de un hormiguero. In-Game asset. 2d
mesa de elaboracion de tierra. In-Game asset. 2d
piedra. In-Game asset. 2d. High contrast. No shadows
miga de pan. In-Game asset. 2d. High contrast. No shadows
escudo. In-Game asset. 2d. High contrast. No shadows
rayo fuerte. In-Game asset. 2d. High contrast. No shadows
espada de guerra. In-Game asset. 2d. High contrast. No shadows
rama de madera. In-Game asset. 2d. High contrast. No shadows
gota de agua. In-Game asset. 2d. High contrast. No shadows
barra de vida. In-Game asset. 2d. High contrast. No shadows