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.energy = 100; self.maxEnergy = 100; self.speed = 3; self.isMoving = false; self.targetX = 0; self.targetY = 0; self.moveTo = function (x, y) { self.targetX = x; self.targetY = y; self.isMoving = true; }; 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; self.energy = Math.max(0, self.energy - 0.1); } else { self.x = self.targetX; self.y = self.targetY; self.isMoving = false; } } }; 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; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x90EE90 }); /**** * Game Code ****/ var ant; var anthill; var resources = []; var predators = []; var colonyStrength = 0; var maxColonyStrength = 100; var gamePhase = 'exploration'; // 'exploration', 'returning' // UI Elements var energyBarBg; var energyBar; var strengthText; var resourceCountText; var collectedResources = 0; // Initialize anthill anthill = game.addChild(LK.getAsset('anthill', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 2400 })); // Initialize ant ant = game.addChild(new Ant()); ant.x = anthill.x; ant.y = anthill.y - 100; // Initialize UI energyBarBg = LK.gui.top.addChild(LK.getAsset('energyBackground', { x: 200, y: 100 })); energyBar = LK.gui.top.addChild(LK.getAsset('energyBar', { x: 200, y: 100 })); strengthText = new Text2('Colony Strength: 0/100', { size: 40, fill: 0xFFFFFF }); strengthText.anchor.set(0, 0); strengthText.x = 50; strengthText.y = 150; 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; LK.gui.top.addChild(resourceCountText); // 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); } // Initialize world for (var i = 0; i < 15; i++) { spawnResource(); } for (var i = 0; i < 3; i++) { spawnPredator(); } // Resource spawn timer var resourceSpawnTimer = 0; game.down = function (x, y, obj) { if (ant.energy > 0) { ant.moveTo(x, y); } }; game.update = function () { // Update energy bar var energyPercent = ant.energy / ant.maxEnergy; energyBar.scaleX = energyPercent; // Update UI text strengthText.setText('Colony Strength: ' + colonyStrength + '/' + maxColonyStrength); resourceCountText.setText('Resources: ' + collectedResources); // 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)) { 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)) { LK.getSound('danger').play(); ant.energy = Math.max(0, ant.energy - 20); // Flash effect LK.effects.flashObject(ant, 0xFF0000, 500); // 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 if ant is at anthill (resource return) var distanceToAnthill = Math.sqrt(Math.pow(ant.x - anthill.x, 2) + Math.pow(ant.y - anthill.y, 2)); if (distanceToAnthill < 100) { // Restore some energy when at anthill ant.energy = Math.min(ant.maxEnergy, ant.energy + 1); } // Game over conditions if (ant.energy <= 0) { LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); } // Win condition if (colonyStrength >= maxColonyStrength) { LK.showYouWin(); } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,238 @@
-/****
+/****
+* 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.energy = 100;
+ self.maxEnergy = 100;
+ self.speed = 3;
+ self.isMoving = false;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.moveTo = function (x, y) {
+ self.targetX = x;
+ self.targetY = y;
+ self.isMoving = true;
+ };
+ 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;
+ self.energy = Math.max(0, self.energy - 0.1);
+ } else {
+ self.x = self.targetX;
+ self.y = self.targetY;
+ self.isMoving = false;
+ }
+ }
+ };
+ 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;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x90EE90
+});
+
+/****
+* Game Code
+****/
+var ant;
+var anthill;
+var resources = [];
+var predators = [];
+var colonyStrength = 0;
+var maxColonyStrength = 100;
+var gamePhase = 'exploration'; // 'exploration', 'returning'
+// UI Elements
+var energyBarBg;
+var energyBar;
+var strengthText;
+var resourceCountText;
+var collectedResources = 0;
+// Initialize anthill
+anthill = game.addChild(LK.getAsset('anthill', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 2400
+}));
+// Initialize ant
+ant = game.addChild(new Ant());
+ant.x = anthill.x;
+ant.y = anthill.y - 100;
+// Initialize UI
+energyBarBg = LK.gui.top.addChild(LK.getAsset('energyBackground', {
+ x: 200,
+ y: 100
+}));
+energyBar = LK.gui.top.addChild(LK.getAsset('energyBar', {
+ x: 200,
+ y: 100
+}));
+strengthText = new Text2('Colony Strength: 0/100', {
+ size: 40,
+ fill: 0xFFFFFF
+});
+strengthText.anchor.set(0, 0);
+strengthText.x = 50;
+strengthText.y = 150;
+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;
+LK.gui.top.addChild(resourceCountText);
+// 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);
+}
+// Initialize world
+for (var i = 0; i < 15; i++) {
+ spawnResource();
+}
+for (var i = 0; i < 3; i++) {
+ spawnPredator();
+}
+// Resource spawn timer
+var resourceSpawnTimer = 0;
+game.down = function (x, y, obj) {
+ if (ant.energy > 0) {
+ ant.moveTo(x, y);
+ }
+};
+game.update = function () {
+ // Update energy bar
+ var energyPercent = ant.energy / ant.maxEnergy;
+ energyBar.scaleX = energyPercent;
+ // Update UI text
+ strengthText.setText('Colony Strength: ' + colonyStrength + '/' + maxColonyStrength);
+ resourceCountText.setText('Resources: ' + collectedResources);
+ // 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)) {
+ 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)) {
+ LK.getSound('danger').play();
+ ant.energy = Math.max(0, ant.energy - 20);
+ // Flash effect
+ LK.effects.flashObject(ant, 0xFF0000, 500);
+ // 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 if ant is at anthill (resource return)
+ var distanceToAnthill = Math.sqrt(Math.pow(ant.x - anthill.x, 2) + Math.pow(ant.y - anthill.y, 2));
+ if (distanceToAnthill < 100) {
+ // Restore some energy when at anthill
+ ant.energy = Math.min(ant.maxEnergy, ant.energy + 1);
+ }
+ // Game over conditions
+ if (ant.energy <= 0) {
+ LK.effects.flashScreen(0xFF0000, 1000);
+ LK.showGameOver();
+ }
+ // Win condition
+ if (colonyStrength >= maxColonyStrength) {
+ LK.showYouWin();
+ }
+};
\ No newline at end of file
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