User prompt
El problema es que salto directo a la ultima wave, quiero que sea sucesivo, empieza el juego en la wave 1, mato 10 enemigos y paso a la 2 que tendra 15, a la 3 que tendra 20 y asi sucesivamente hasta llegar a la wave numero 20
User prompt
quiero que despues de matar a todos los enemigos pases a la siguiente wave
User prompt
algo esta mal, gano la primer wave y paso directo a la wave 20, deberia pasar a la 2 y luego a la 3, a la 4 y asi sucesivamente
User prompt
parece que hay un error o bug y despues de pasar la 1er wave se vuelve loco y rapidamente pasa a la wave 121, deberia ser poco a poco, matar x cantidad en la wave 1, un poco mas de enemigos en la wave 2 y asi sucesivamente, quiero que haya un limite de 20 waves
Code edit (1 edits merged)
Please save this source code
User prompt
Brotato Survivor
Initial prompt
crea un juego clon de brotato
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bullet = 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 = 25;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
};
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 = 50;
self.speed = 1.5;
self.damage = 20;
self.update = function () {
if (player) {
var angle = Math.atan2(player.y - self.y, player.x - self.x);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.speed = 4;
self.shootCooldown = 0;
self.shootRate = 20; // frames between shots
self.update = function () {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
// Auto-shoot at nearest enemy
if (self.shootCooldown <= 0 && enemies.length > 0) {
var nearestEnemy = null;
var nearestDistance = Infinity;
for (var i = 0; i < enemies.length; i++) {
var distance = Math.sqrt(Math.pow(enemies[i].x - self.x, 2) + Math.pow(enemies[i].y - self.y, 2));
if (distance < nearestDistance) {
nearestDistance = distance;
nearestEnemy = enemies[i];
}
}
if (nearestEnemy && nearestDistance < 400) {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
var angle = Math.atan2(nearestEnemy.y - self.y, nearestEnemy.x - self.x);
bullet.velocityX = Math.cos(angle) * 8;
bullet.velocityY = Math.sin(angle) * 8;
bullets.push(bullet);
game.addChild(bullet);
self.shootCooldown = self.shootRate;
LK.getSound('shoot').play();
}
}
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = 'health'; // health, speed, damage, rate
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F4F2F
});
/****
* Game Code
****/
// Game variables
var player;
var bullets = [];
var enemies = [];
var powerups = [];
var currentWave = 1;
var enemiesRemaining = 0;
var waveStartDelay = 0;
var gameStarted = false;
var dragTarget = null;
// Arena bounds
var arenaLeft = 200;
var arenaRight = 1848;
var arenaTop = 300;
var arenaBottom = 2432;
// UI Elements
var healthText = new Text2('Health: 100', {
size: 60,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthText);
healthText.x = 120;
healthText.y = 20;
var waveText = new Text2('Wave: 1', {
size: 60,
fill: 0xFFFFFF
});
waveText.anchor.set(0.5, 0);
LK.gui.top.addChild(waveText);
waveText.y = 20;
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFF00
});
scoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreText);
scoreText.x = -20;
scoreText.y = 20;
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
function startWave() {
var enemiesToSpawn = Math.min(5 + currentWave * 2, 25);
enemiesRemaining = enemiesToSpawn;
for (var i = 0; i < enemiesToSpawn; i++) {
LK.setTimeout(function () {
spawnEnemy();
}, i * 200);
}
}
function spawnEnemy() {
var enemy = new Enemy();
// Spawn at random edge
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// top
enemy.x = arenaLeft + Math.random() * (arenaRight - arenaLeft);
enemy.y = arenaTop - 50;
break;
case 1:
// right
enemy.x = arenaRight + 50;
enemy.y = arenaTop + Math.random() * (arenaBottom - arenaTop);
break;
case 2:
// bottom
enemy.x = arenaLeft + Math.random() * (arenaRight - arenaLeft);
enemy.y = arenaBottom + 50;
break;
case 3:
// left
enemy.x = arenaLeft - 50;
enemy.y = arenaTop + Math.random() * (arenaBottom - arenaTop);
break;
}
// Scale enemy health with wave
enemy.health = 50 + (currentWave - 1) * 15;
enemy.speed = 1.5 + (currentWave - 1) * 0.1;
enemies.push(enemy);
game.addChild(enemy);
}
function spawnPowerUp(x, y) {
var powerup = new PowerUp();
powerup.x = x;
powerup.y = y;
var types = ['health', 'speed', 'damage', 'rate'];
powerup.type = types[Math.floor(Math.random() * types.length)];
powerups.push(powerup);
game.addChild(powerup);
}
function collectPowerUp(powerup) {
switch (powerup.type) {
case 'health':
player.health = Math.min(player.health + 30, player.maxHealth);
break;
case 'speed':
player.speed = Math.min(player.speed + 0.5, 8);
break;
case 'damage':
// Increase bullet damage for all future bullets
break;
case 'rate':
player.shootRate = Math.max(player.shootRate - 3, 5);
break;
}
LK.getSound('powerupCollect').play();
}
function handleMove(x, y, obj) {
if (dragTarget === player) {
player.x = Math.max(arenaLeft + 40, Math.min(arenaRight - 40, x));
player.y = Math.max(arenaTop + 40, Math.min(arenaBottom - 40, y));
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
dragTarget = player;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragTarget = null;
};
// Start first wave
LK.setTimeout(function () {
startWave();
gameStarted = true;
}, 1000);
game.update = function () {
if (!gameStarted) return;
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Remove bullets that go off screen
if (bullet.x < 0 || bullet.x > 2048 || bullet.y < 0 || bullet.y > 2732) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
enemy.health -= bullet.damage;
LK.effects.flashObject(enemy, 0xFFFFFF, 200);
LK.getSound('enemyHit').play();
bullet.destroy();
bullets.splice(i, 1);
if (enemy.health <= 0) {
var enemyX = enemy.x;
var enemyY = enemy.y;
enemy.destroy();
enemies.splice(j, 1);
enemiesRemaining--;
LK.setScore(LK.getScore() + 10);
scoreText.setText('Score: ' + LK.getScore());
// 20% chance to drop powerup
if (Math.random() < 0.2) {
spawnPowerUp(enemyX, enemyY);
}
}
break;
}
}
}
// Check player-enemy collisions
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (player.intersects(enemy)) {
player.health -= enemy.damage;
LK.effects.flashObject(player, 0xFF0000, 300);
enemy.destroy();
enemies.splice(i, 1);
if (player.health <= 0) {
LK.showGameOver();
return;
}
}
}
// Check powerup collection
for (var i = powerups.length - 1; i >= 0; i--) {
var powerup = powerups[i];
if (player.intersects(powerup)) {
collectPowerUp(powerup);
powerup.destroy();
powerups.splice(i, 1);
}
}
// Update UI
healthText.setText('Health: ' + player.health);
// Check wave completion
if (enemiesRemaining <= 0 && enemies.length === 0) {
currentWave++;
if (currentWave > 20) {
LK.showYouWin();
return;
}
waveText.setText('Wave: ' + currentWave);
// Brief pause between waves
LK.setTimeout(function () {
startWave();
}, 2000);
// Heal player slightly between waves
player.health = Math.min(player.health + 10, player.maxHealth);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -274,9 +274,8 @@
player.health -= enemy.damage;
LK.effects.flashObject(player, 0xFF0000, 300);
enemy.destroy();
enemies.splice(i, 1);
- enemiesRemaining--;
if (player.health <= 0) {
LK.showGameOver();
return;
}
@@ -295,8 +294,12 @@
healthText.setText('Health: ' + player.health);
// Check wave completion
if (enemiesRemaining <= 0 && enemies.length === 0) {
currentWave++;
+ if (currentWave > 20) {
+ LK.showYouWin();
+ return;
+ }
waveText.setText('Wave: ' + currentWave);
// Brief pause between waves
LK.setTimeout(function () {
startWave();
un puerco de cuerpo completo sin fondo y que se vea tierno pero con expersion de la cara enojado In-Game asset. 2d. High contrast. No shadows
dibuja al animal zorra con expresion malvada estilo igual animado cuerpo completo. In-Game asset. 2d. High contrast. No shadows
una bala estilo cartoon. In-Game asset. 2d. High contrast. No shadows
una valla de corral animada. In-Game asset. 2d. High contrast. No shadows
tierra de corral, textura de corral de granja nocturna. In-Game asset. 2d. High contrast. No shadows
corn with toon style. In-Game asset. 2d. High contrast. No shadows
onda de corte blanca estilo animada. In-Game asset. 2d. High contrast. No shadows