User prompt
reduce mas la velocidad del player y dame la opcion de poner iconos, imagenes en cada uno de los power up y ese mismo se vera reflejado en el juego ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Uncaught TypeError: hoverButton.attachAsset is not a function' in or related to this line: 'hoverButton.glowEffect = hoverButton.attachAsset('ground', {' Line Number: 862
User prompt
mejora la interfaz y la UI de cuando seleccionamos un power up y ponle imagenes de fondo de color y estilo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
restringe el movimiento del player a algo lento
User prompt
Haz un acercamiento al juego para ver con mas detalle todo
Code edit (1 edits merged)
Please save this source code
User prompt
preferiria que tanto player como enemy tuvieran la misma animacion de agrandar y regresar a su tamaño generando animacion ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
hazle una animacion a los sprites del player y de los enemigos para que se vean mejor ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
ahora haz que la musica se escuche en el juego , crea un menu con un boton de start para iniciar el juego y con una imagen para poner despues un diseño o diseños del juego ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
modifica para que pueda elegir la imagen de los ataques del boss y ponerle alguna imagen/asset
User prompt
modifica para que el boss pueda lanzar como ondas de corte y se acerque con mas velocidad hacia el player ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
modifica un poco el tiempo que dura el boss , que aparezca por la mitad de la ronda, las rondas deben durar 1min todas
User prompt
quiero que casi al final de la ronda salga un enemigo mas grande que los demas en tamaño, vida y daño, que ademas pueda atacar a corta distancia con un tipo efecto de corte de garra ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
quiero que lo que suelten los enemigos al morir se pueda modificar para poner un elote / maiz y recogerlo apra incrementar el score, ademas en la UI quiero cambiar la palabra "Score" por una imagen de un elote ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
veo que el fondo es verde me gustaria que estuviera todo mas ambientado a una grande de noche, puedes redimenzionar el juego para que en la parte de arriba se vea el diseño de granja nocturna, ademas preferiria un zoom al gameplay, lo veo todo muy pequeño ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
quiero tambien poder agregar mejores diseños a la UI ejemplo de fondo en el juego quiero un tipo corral y en los bordes que sean vallas de corral
User prompt
siguen apareciendo power ups en las rondas, ejempo salio una torreta y solo debe salir si la elijo, por favor revisa la logica
User prompt
no puedo elegir los power up en la UI no pasa nada al clickear el boton ademas durante la ronda aparecen powerup y no, solo deberian soltar los enemigos puntos para el score recogibles ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
el power up de vida/health debe mejorar la vida maxima del jugador y si por ejemplo tienes 100 de vida y al final de la ronda quedaste 10/100 recuperas la vida al pasar de ronda, si eliges el power up de vida, podriamos digamos en vez de seguir con 100/100 ahora tengas mejor vida maxima total, ejemplo 110/110 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
mejora un poco la UI de los powerup y asegura que si selecciones x power up de el efecto correcto ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
quiero solo 3 power up 1. subir la health del player, 2. mejorar el disparo, 3. poner una mini torreta alida que tambien dispare y se posicione en alguna coordenada random del mapa ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
no se ve reflejado el power up que eliges, ejemplo, comenze con 100 de vida en ronda 1 y elegi el power up de incrementar la vida, pero no lo veo reflejado en la UI
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'cost')' in or related to this line: 'if (LK.getScore() >= obj.parent.cost) {' Line Number: 242
User prompt
ahora cada vez que gane una ronda y antes de empezar la siguiente haya una pantalla para elegir un power up y consuma Score, tambien quiero que cambie la logica y sean rondas por tiempo y cada ronda dure un poco mas y con mas enemigos, mejorar tambien algunos enemigos mas grandes y resistentes dependiendo del numero de ronda ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
revisa el error ya que gano el juego en la primera ronda, debo de jugar 20 rondas
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BossEnemy = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('bossEnemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 300;
self.speed = 2.5; // Increased speed for faster approach
self.damage = 50;
self.waveNumber = currentWave;
self.clawAttackCooldown = 0;
self.clawAttackRange = 150;
self.clawAttackRate = 120; // 2 seconds between claw attacks
self.waveAttackCooldown = 0;
self.waveAttackRange = 400; // Longer range for wave attacks
self.waveAttackRate = 180; // 3 seconds between wave attacks
// Visual effect for claw attack
self.clawEffect = null;
// Animation properties
self.animationOffset = Math.random() * Math.PI * 2;
self.breathingSpeed = 0.08;
self.intimidationFactor = 1;
self.update = function () {
// Add intimidating breathing animation
var breathe = Math.sin(LK.ticks * self.breathingSpeed + self.animationOffset) * 0.15;
graphics.scaleX = self.intimidationFactor + breathe;
graphics.scaleY = self.intimidationFactor + breathe * 0.7;
// Add slight rotation sway
graphics.rotation = Math.sin(LK.ticks * 0.05 + self.animationOffset) * 0.1;
// Add color pulsing for menacing effect
var pulseIntensity = Math.sin(LK.ticks * 0.1 + self.animationOffset) * 0.3 + 0.7;
if (graphics.tint === 0xFFFFFF || graphics.tint === undefined) {
graphics.tint = 0xFF0000;
}
if (player) {
var angle = Math.atan2(player.y - self.y, player.x - self.x);
var distanceToPlayer = Math.sqrt(Math.pow(player.x - self.x, 2) + Math.pow(player.y - self.y, 2));
// Move towards player with increased speed
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
// Claw attack logic
if (self.clawAttackCooldown > 0) {
self.clawAttackCooldown--;
}
// Wave attack logic
if (self.waveAttackCooldown > 0) {
self.waveAttackCooldown--;
}
// Prioritize wave attacks at medium range, claw attacks at close range
if (distanceToPlayer <= self.waveAttackRange && distanceToPlayer > self.clawAttackRange && self.waveAttackCooldown <= 0) {
self.performWaveAttack();
self.waveAttackCooldown = self.waveAttackRate;
} else if (distanceToPlayer <= self.clawAttackRange && self.clawAttackCooldown <= 0) {
self.performClawAttack();
self.clawAttackCooldown = self.clawAttackRate;
}
}
};
self.performWaveAttack = function () {
// Create multiple cutting wave projectiles
var angleToPlayer = Math.atan2(player.y - self.y, player.x - self.x);
// Create 3 waves spread in a cone
for (var i = 0; i < 3; i++) {
var waveAngle = angleToPlayer + (i - 1) * 0.3; // Spread waves in cone
var wave = game.addChild(new Container());
// Create wave visual
var waveGraphic = wave.attachAsset('waveAttack', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 1.2
});
waveGraphic.tint = 0xFF3333;
waveGraphic.alpha = 0.95;
wave.rotation = waveAngle;
wave.x = self.x;
wave.y = self.y;
wave.velocityX = Math.cos(waveAngle) * 6;
wave.velocityY = Math.sin(waveAngle) * 6;
wave.damage = self.damage * 0.8; // Slightly less damage than claw
wave.lifeTime = 0;
wave.maxLifeTime = 120; // 2 seconds at 60fps
// Add wave to bullets array for collision detection
if (!bossWaves) bossWaves = [];
bossWaves.push(wave);
// Add pulsing animation to wave
tween(waveGraphic, {
scaleX: 2.5,
alpha: 0.7
}, {
duration: 200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(waveGraphic, {
scaleX: 2,
alpha: 0.9
}, {
duration: 200,
easing: tween.easeInOut
});
}
});
}
// Visual effect at boss position
LK.effects.flashObject(self, 0xFF6666, 300);
LK.getSound('clawAttack').play(); // Reuse claw sound for waves
};
self.performClawAttack = function () {
// Create visual claw effect
if (self.clawEffect) {
self.clawEffect.destroy();
}
self.clawEffect = self.addChild(LK.getAsset('fence', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 0.5
}));
self.clawEffect.tint = 0xFF4444;
self.clawEffect.alpha = 0.8;
// Animate claw slash effect
var angle = Math.atan2(player.y - self.y, player.x - self.x);
self.clawEffect.rotation = angle;
tween(self.clawEffect, {
scaleX: 4,
scaleY: 1,
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
if (self.clawEffect) {
self.clawEffect.destroy();
self.clawEffect = null;
}
}
});
// Deal damage to player if still in range
var currentDistance = Math.sqrt(Math.pow(player.x - self.x, 2) + Math.pow(player.y - self.y, 2));
if (currentDistance <= self.clawAttackRange) {
player.health -= self.damage;
LK.effects.flashObject(player, 0xFF0000, 500);
LK.getSound('clawAttack').play();
}
// Screen shake effect for dramatic impact
LK.effects.flashScreen(0xFF4444, 200);
};
return self;
});
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 = Bullet.prototype.baseDamage || 25;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
};
return self;
});
var Corn = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('corn', {
anchorX: 0.5,
anchorY: 0.5
});
self.scoreValue = 10;
graphics.tint = 0xFFD700; // Golden corn color
// Add floating animation
self.floatOffset = Math.random() * Math.PI * 2;
self.baseY = 0;
self.update = function () {
if (self.baseY === 0) self.baseY = self.y;
self.y = self.baseY + Math.sin(LK.ticks * 0.1 + self.floatOffset) * 5;
};
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.waveNumber = currentWave;
// Animation properties
self.animationOffset = Math.random() * Math.PI * 2;
self.rotationSpeed = 0.02 + Math.random() * 0.02;
self.update = function () {
// Add menacing wobble animation
graphics.rotation += self.rotationSpeed;
var wobble = Math.sin(LK.ticks * 0.2 + self.animationOffset) * 0.1;
graphics.scaleX = 1 + wobble;
graphics.scaleY = 1 - wobble * 0.5;
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 MiniTurret = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
graphics.tint = 0x00FFFF;
self.shootCooldown = 0;
self.shootRate = 40; // Slower than player
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 < 350) {
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) * 6;
bullet.velocityY = Math.sin(angle) * 6;
bullets.push(bullet);
game.addChild(bullet);
self.shootCooldown = self.shootRate;
LK.getSound('shoot').play();
}
}
};
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
// Animation properties
self.animationOffset = Math.random() * Math.PI * 2;
self.baseY = 0;
self.isAnimating = false;
self.update = function () {
// Initialize base position for floating animation
if (self.baseY === 0) self.baseY = self.y;
// Add subtle floating animation
graphics.y = Math.sin(LK.ticks * 0.15 + self.animationOffset) * 3;
// Add subtle scale pulsing
var scalePulse = 1 + Math.sin(LK.ticks * 0.1 + self.animationOffset) * 0.05;
graphics.scaleX = scalePulse;
graphics.scaleY = scalePulse;
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;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0F1A2E // Dark night blue
});
/****
* Game Code
****/
// Game variables
var player;
var bullets = [];
var enemies = [];
var miniTurrets = [];
var cornDrops = [];
var bossWaves = [];
var currentWave = 1;
var enemiesRemaining = 0;
var waveStartDelay = 0;
var gameStarted = false;
var showingMenu = true;
var menuContainer = null;
var dragTarget = null;
var waveInProgress = false;
var showingPowerUpSelection = false;
var waveTimer = 0;
var waveTimeLimit = 0;
var enemySpawnTimer = 0;
var enemySpawnRate = 0;
var powerUpSelectionUI = null;
// Create nighttime farm scenery in top area
var farmSceneryContainer = game.addChild(new Container());
// Night sky gradient background
var skyBg = farmSceneryContainer.attachAsset('ground', {
anchorX: 0,
anchorY: 0,
scaleX: 10.24,
scaleY: 2
});
skyBg.x = 0;
skyBg.y = 0;
skyBg.tint = 0x1A2B4A; // Dark night blue
// Add some farm buildings silhouettes
var barn = farmSceneryContainer.attachAsset('fence', {
anchorX: 0,
anchorY: 0,
scaleX: 8,
scaleY: 6
});
barn.x = 300;
barn.y = 80;
barn.tint = 0x2C1810; // Dark barn color
var farmhouse = farmSceneryContainer.attachAsset('fence', {
anchorX: 0,
anchorY: 0,
scaleX: 6,
scaleY: 4
});
farmhouse.x = 1200;
farmhouse.y = 120;
farmhouse.tint = 0x3D2817; // Dark house color
// Add some trees silhouettes
for (var t = 0; t < 5; t++) {
var tree = farmSceneryContainer.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 1,
scaleX: 2,
scaleY: 3
});
tree.x = 150 + t * 350;
tree.y = 200;
tree.tint = 0x0D1B0D; // Very dark green for tree silhouettes
}
// Add stars
for (var s = 0; s < 20; s++) {
var star = farmSceneryContainer.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
star.x = Math.random() * 2048;
star.y = Math.random() * 180;
star.tint = 0xFFFFAA; // Yellowish white stars
}
// Arena bounds - zoomed in and repositioned for better gameplay
var arenaLeft = 300;
var arenaRight = 1748;
var arenaTop = 450;
var arenaBottom = 2300;
// Create corral ground background
var groundContainer = game.addChild(new Container());
var groundTileWidth = 200;
var groundTileHeight = 200;
var tilesX = Math.ceil((arenaRight - arenaLeft) / groundTileWidth);
var tilesY = Math.ceil((arenaBottom - arenaTop) / groundTileHeight);
for (var gx = 0; gx < tilesX; gx++) {
for (var gy = 0; gy < tilesY; gy++) {
var groundTile = groundContainer.attachAsset('ground', {
anchorX: 0,
anchorY: 0
});
groundTile.x = arenaLeft + gx * groundTileWidth;
groundTile.y = arenaTop + gy * groundTileHeight;
// Add nighttime ground colors
if ((gx + gy) % 2 === 0) {
groundTile.tint = 0x3A5F3A; // Dark nighttime grass green
} else {
groundTile.tint = 0x2F4F2F; // Slightly different dark green
}
}
}
// Create fence borders
var fenceContainer = game.addChild(new Container());
// Top fence
var topFenceLength = Math.ceil((arenaRight - arenaLeft) / 100);
for (var i = 0; i < topFenceLength; i++) {
var topFence = fenceContainer.attachAsset('fence', {
anchorX: 0,
anchorY: 0.5
});
topFence.x = arenaLeft + i * 100;
topFence.y = arenaTop - 10;
}
// Bottom fence
for (var i = 0; i < topFenceLength; i++) {
var bottomFence = fenceContainer.attachAsset('fence', {
anchorX: 0,
anchorY: 0.5
});
bottomFence.x = arenaLeft + i * 100;
bottomFence.y = arenaBottom + 10;
}
// Left fence (vertical)
var leftFenceLength = Math.ceil((arenaBottom - arenaTop) / 100);
for (var i = 0; i < leftFenceLength; i++) {
var leftFence = fenceContainer.attachAsset('fence', {
anchorX: 0.5,
anchorY: 0,
scaleX: 0.2,
scaleY: 5
});
leftFence.x = arenaLeft - 10;
leftFence.y = arenaTop + i * 100;
}
// Right fence (vertical)
for (var i = 0; i < leftFenceLength; i++) {
var rightFence = fenceContainer.attachAsset('fence', {
anchorX: 0.5,
anchorY: 0,
scaleX: 0.2,
scaleY: 5
});
rightFence.x = arenaRight + 10;
rightFence.y = arenaTop + i * 100;
}
// Corner posts for authenticity
var corners = [{
x: arenaLeft - 10,
y: arenaTop - 10
}, {
x: arenaRight + 10,
y: arenaTop - 10
}, {
x: arenaLeft - 10,
y: arenaBottom + 10
}, {
x: arenaRight + 10,
y: arenaBottom + 10
}];
for (var c = 0; c < corners.length; c++) {
var cornerPost = fenceContainer.attachAsset('fence', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 2
});
cornerPost.x = corners[c].x;
cornerPost.y = corners[c].y;
cornerPost.tint = 0x2C1810; // Very dark brown for nighttime posts
}
// UI Elements
var healthText = new Text2('Health: 100/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;
// Create corn icon for score display
var cornIcon = LK.getAsset('corn', {
anchorX: 1,
anchorY: 0,
scaleX: 1.5,
scaleY: 1.5
});
cornIcon.tint = 0xFFD700;
LK.gui.topRight.addChild(cornIcon);
cornIcon.x = -120;
cornIcon.y = 20;
var scoreText = new Text2('0', {
size: 60,
fill: 0xFFFF00
});
scoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreText);
scoreText.x = -20;
scoreText.y = 20;
var timerText = new Text2('Time: 30', {
size: 60,
fill: 0x00FFFF
});
timerText.anchor.set(0.5, 0);
LK.gui.top.addChild(timerText);
timerText.y = 100;
// Initialize player
player = game.addChild(new Player());
player.x = (arenaLeft + arenaRight) / 2; // Center horizontally in arena
player.y = (arenaTop + arenaBottom) / 2; // Center vertically in arena
// Create power-up selection UI (initially hidden)
function createPowerUpSelectionUI() {
if (powerUpSelectionUI) {
powerUpSelectionUI.destroy();
}
powerUpSelectionUI = game.addChild(new Container());
// Background overlay
var overlay = powerUpSelectionUI.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 34,
scaleY: 45,
alpha: 0.8
});
overlay.x = 1024;
overlay.y = 1366;
overlay.tint = 0x000000;
// Title
var titleText = new Text2('Choose Power-Up', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 800;
powerUpSelectionUI.addChild(titleText);
// Power-up options
var options = [{
type: 'health',
name: 'Health +50',
cost: 50,
color: 0xFF0000
}, {
type: 'shooting',
name: 'Better Shooting',
cost: 100,
color: 0xFFFF00
}, {
type: 'turret',
name: 'Mini Turret Ally',
cost: 150,
color: 0x00FFFF
}];
for (var i = 0; i < options.length; i++) {
var option = options[i];
var button = powerUpSelectionUI.addChild(new Container());
var buttonBg = button.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 2
});
buttonBg.tint = option.color;
var buttonText = new Text2(option.name + ' - ' + option.cost + ' pts', {
size: 50,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
button.addChild(buttonText);
button.x = 1024;
button.y = 1000 + i * 150;
button.powerUpType = option.type;
button.cost = option.cost;
button.originalScale = 1;
button.down = function (x, y, obj) {
if (LK.getScore() >= button.cost) {
// Visual feedback on successful purchase
tween(button, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150,
onFinish: function onFinish() {
tween(button, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
}
});
applyPowerUp(button.powerUpType);
LK.setScore(LK.getScore() - button.cost);
scoreText.setText(LK.getScore().toString());
hidePowerUpSelection();
} else {
// Visual feedback on insufficient funds
tween(button, {
tint: 0xFF0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(button, {
tint: 0xFFFFFF
}, {
duration: 200
});
}
});
}
};
// Add hover effect
button.move = function (x, y, obj) {
var hoverButton = obj;
if (!hoverButton.isHovering) {
hoverButton.isHovering = true;
tween(hoverButton, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200
});
}
};
}
// Skip button
var skipButton = powerUpSelectionUI.addChild(new Container());
var skipBg = skipButton.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 6,
scaleY: 1.5
});
skipBg.tint = 0x666666;
var skipText = new Text2('Skip', {
size: 50,
fill: 0xFFFFFF
});
skipText.anchor.set(0.5, 0.5);
skipButton.addChild(skipText);
skipButton.x = 1024;
skipButton.y = 1700;
skipButton.down = function (x, y, obj) {
tween(skipButton, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150,
onFinish: function onFinish() {
tween(skipButton, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
}
});
hidePowerUpSelection();
};
skipButton.move = function (x, y, obj) {
var hoverSkip = obj;
if (!hoverSkip.isHovering) {
hoverSkip.isHovering = true;
tween(hoverSkip, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200
});
}
};
powerUpSelectionUI.alpha = 0;
// Animate all buttons to start from scale 0 and grow in
for (var k = 0; k < powerUpSelectionUI.children.length; k++) {
var child = powerUpSelectionUI.children[k];
if (child !== overlay && child !== titleText) {
child.scaleX = 0;
child.scaleY = 0;
tween(child, {
scaleX: 1,
scaleY: 1
}, {
duration: 400 + k * 100,
easing: tween.bounceOut
});
}
}
tween(powerUpSelectionUI, {
alpha: 1
}, {
duration: 300
});
}
function showPowerUpSelection() {
showingPowerUpSelection = true;
createPowerUpSelectionUI();
}
function hidePowerUpSelection() {
showingPowerUpSelection = false;
if (powerUpSelectionUI) {
tween(powerUpSelectionUI, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
powerUpSelectionUI.destroy();
powerUpSelectionUI = null;
startNextWave();
}
});
}
}
function applyPowerUp(type) {
switch (type) {
case 'health':
player.maxHealth += 50;
player.health = player.maxHealth; // Heal to full new max health
break;
case 'shooting':
// Improve shooting: increase damage and fire rate
Bullet.prototype.baseDamage = (Bullet.prototype.baseDamage || 25) + 15;
player.shootRate = Math.max(player.shootRate - 5, 8);
break;
case 'turret':
// Create mini turret at random position
var turret = new MiniTurret();
turret.x = arenaLeft + Math.random() * (arenaRight - arenaLeft);
turret.y = arenaTop + Math.random() * (arenaBottom - arenaTop);
miniTurrets.push(turret);
game.addChild(turret);
break;
}
// Update UI immediately after applying power-up
healthText.setText('Health: ' + player.health + '/' + player.maxHealth);
}
function startWave() {
if (waveInProgress) return;
waveInProgress = {
bossSpawned: false
};
waveTimer = 0;
waveTimeLimit = 60 * 60; // 1 minute for all waves at 60fps
enemySpawnTimer = 0;
enemySpawnRate = Math.max(120 - currentWave * 5, 30); // Spawn every 2-0.5 seconds
console.log('Starting wave ' + currentWave + ' for ' + waveTimeLimit / 60 + ' seconds');
}
function startNextWave() {
waveInProgress = {
bossSpawned: false
};
waveTimer = 0;
waveTimeLimit = 60 * 60; // 1 minute for all waves at 60fps
enemySpawnTimer = 0;
enemySpawnRate = Math.max(120 - currentWave * 5, 30);
console.log('Starting wave ' + currentWave + ' for ' + waveTimeLimit / 60 + ' seconds');
}
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 with wave - bigger and more resistant
var sizeMultiplier = 1 + (currentWave - 1) * 0.15;
var healthMultiplier = 1 + (currentWave - 1) * 0.5;
enemy.children[0].scaleX = sizeMultiplier;
enemy.children[0].scaleY = sizeMultiplier;
enemy.health = Math.floor(50 * healthMultiplier);
enemy.speed = 1.5 + (currentWave - 1) * 0.1;
enemy.damage = 20 + (currentWave - 1) * 5;
enemy.waveNumber = currentWave;
// Tint stronger enemies
if (currentWave > 5) {
enemy.children[0].tint = 0xFF0000 + currentWave * 0x110000;
}
enemies.push(enemy);
game.addChild(enemy);
}
function spawnBossEnemy() {
var boss = new BossEnemy();
// Spawn at random edge
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// top
boss.x = arenaLeft + Math.random() * (arenaRight - arenaLeft);
boss.y = arenaTop - 80;
break;
case 1:
// right
boss.x = arenaRight + 80;
boss.y = arenaTop + Math.random() * (arenaBottom - arenaTop);
break;
case 2:
// bottom
boss.x = arenaLeft + Math.random() * (arenaRight - arenaLeft);
boss.y = arenaBottom + 80;
break;
case 3:
// left
boss.x = arenaLeft - 80;
boss.y = arenaTop + Math.random() * (arenaBottom - arenaTop);
break;
}
// Scale boss with wave - much bigger and more resistant than regular enemies
var sizeMultiplier = 1.5 + (currentWave - 1) * 0.2;
var healthMultiplier = 2 + (currentWave - 1) * 0.8;
boss.children[0].scaleX = sizeMultiplier;
boss.children[0].scaleY = sizeMultiplier;
boss.health = Math.floor(300 * healthMultiplier);
boss.speed = 1 + (currentWave - 1) * 0.05; // Slower than regular enemies
boss.damage = 50 + (currentWave - 1) * 10;
boss.waveNumber = currentWave;
// Special boss tinting - darker red with wave progression
boss.children[0].tint = 0x8B0000 + currentWave * 0x110000;
// Add menacing glow effect
tween(boss.children[0], {
tint: 0xFF0000
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(boss.children[0], {
tint: 0x8B0000 + currentWave * 0x110000
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Create looping glow effect
var _glowLoop = function glowLoop() {
tween(boss.children[0], {
tint: 0xFF0000
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(boss.children[0], {
tint: 0x8B0000 + currentWave * 0x110000
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: _glowLoop
});
}
});
};
_glowLoop();
}
});
}
});
enemies.push(boss);
game.addChild(boss);
// Screen flash to announce boss arrival
LK.effects.flashScreen(0xFF0000, 800);
}
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;
};
// Create start menu
function createStartMenu() {
menuContainer = game.addChild(new Container());
// Menu background overlay
var menuBg = menuContainer.attachAsset('ground', {
anchorX: 0,
anchorY: 0,
scaleX: 10.24,
scaleY: 13.66
});
menuBg.tint = 0x0A0A0A;
menuBg.alpha = 0.9;
// Game title
var titleText = new Text2('CORN DEFENSE', {
size: 120,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 400;
menuContainer.addChild(titleText);
// Game design preview area
var previewContainer = menuContainer.addChild(new Container());
// Preview background
var previewBg = previewContainer.attachAsset('ground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 6,
scaleY: 4
});
previewBg.x = 1024;
previewBg.y = 850;
previewBg.tint = 0x3A5F3A;
// Preview elements - show mini versions of game assets
var previewPlayer = previewContainer.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
previewPlayer.x = 924;
previewPlayer.y = 850;
var previewEnemy = previewContainer.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
previewEnemy.x = 1024;
previewEnemy.y = 800;
previewEnemy.tint = 0xFF4444;
var previewBoss = previewContainer.attachAsset('bossEnemy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
});
previewBoss.x = 1124;
previewBoss.y = 820;
previewBoss.tint = 0x8B0000;
var previewCorn = previewContainer.attachAsset('corn', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.7
});
previewCorn.x = 1024;
previewCorn.y = 900;
previewCorn.tint = 0xFFD700;
// Add floating animation to preview elements
tween(previewPlayer, {
y: previewPlayer.y - 10
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
var _floatLoop = function floatLoop() {
tween(previewPlayer, {
y: previewPlayer.y + 20
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(previewPlayer, {
y: previewPlayer.y - 20
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: _floatLoop
});
}
});
};
_floatLoop();
}
});
// Start button
var startButton = menuContainer.addChild(new Container());
var buttonBg = startButton.attachAsset('ground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 1
});
buttonBg.tint = 0x2E8B57;
buttonBg.x = 0;
buttonBg.y = 0;
var buttonText = new Text2('START GAME', {
size: 70,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
startButton.addChild(buttonText);
startButton.x = 1024;
startButton.y = 1200;
// Button interactions
startButton.down = function (x, y, obj) {
tween(startButton, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 150,
onFinish: function onFinish() {
tween(startButton, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
}
});
startGame();
};
// Instructions text
var instructionsText = new Text2('Drag to move player\nCollect corn to buy upgrades\nSurvive 20 waves!', {
size: 50,
fill: 0xCCCCCC
});
instructionsText.anchor.set(0.5, 0.5);
instructionsText.x = 1024;
instructionsText.y = 1450;
menuContainer.addChild(instructionsText);
// Animate menu entrance
menuContainer.alpha = 0;
tween(menuContainer, {
alpha: 1
}, {
duration: 1000
});
}
function startGame() {
showingMenu = false;
// Fade out menu
tween(menuContainer, {
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
menuContainer.destroy();
menuContainer = null;
// Start background music
LK.playMusic('MusicaFondo1');
// Start first wave
LK.setTimeout(function () {
startWave();
gameStarted = true;
}, 1000);
}
});
}
// Create and show start menu
createStartMenu();
game.update = function () {
if (showingMenu || !gameStarted || showingPowerUpSelection) return;
// Update wave timer and spawn enemies
if (waveInProgress) {
waveTimer++;
enemySpawnTimer++;
// Spawn enemies at intervals
if (enemySpawnTimer >= enemySpawnRate) {
spawnEnemy();
enemySpawnTimer = 0;
}
// Spawn boss enemy when 50% of wave time has passed (once per wave)
var waveProgress = waveTimer / waveTimeLimit;
if (waveProgress >= 0.5 && !waveInProgress.bossSpawned) {
spawnBossEnemy();
waveInProgress.bossSpawned = true;
}
// Update timer display
var timeLeft = Math.max(0, Math.ceil((waveTimeLimit - waveTimer) / 60));
timerText.setText('Time: ' + timeLeft);
// Check wave completion
if (waveTimer >= waveTimeLimit) {
waveInProgress = false;
// Clear remaining enemies
for (var k = enemies.length - 1; k >= 0; k--) {
enemies[k].destroy();
enemies.splice(k, 1);
}
currentWave++;
console.log('Wave ' + (currentWave - 1) + ' completed! Moving to wave ' + currentWave);
if (currentWave > 20) {
LK.showYouWin();
return;
}
waveText.setText('Wave: ' + currentWave);
player.health = player.maxHealth; // Heal to full health between waves
showPowerUpSelection();
return;
}
}
// Update boss wave projectiles
for (var w = bossWaves.length - 1; w >= 0; w--) {
var wave = bossWaves[w];
wave.lifeTime++;
wave.x += wave.velocityX;
wave.y += wave.velocityY;
// Remove waves that are off screen or expired
if (wave.x < 0 || wave.x > 2048 || wave.y < 0 || wave.y > 2732 || wave.lifeTime >= wave.maxLifeTime) {
wave.destroy();
bossWaves.splice(w, 1);
continue;
}
// Check wave-player collision
if (wave.intersects(player)) {
player.health -= wave.damage;
LK.effects.flashObject(player, 0xFF6666, 400);
LK.getSound('enemyHit').play();
wave.destroy();
bossWaves.splice(w, 1);
if (player.health <= 0) {
LK.showGameOver();
return;
}
continue;
}
}
// 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) {
// Drop corn at enemy position
var corn = new Corn();
corn.x = enemy.x;
corn.y = enemy.y;
corn.scoreValue = 10 * enemy.waveNumber;
cornDrops.push(corn);
game.addChild(corn);
enemy.destroy();
enemies.splice(j, 1);
}
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;
}
}
}
// Update corn drops and check collection
for (var c = cornDrops.length - 1; c >= 0; c--) {
var corn = cornDrops[c];
// Check if player collects corn
if (player.intersects(corn)) {
LK.setScore(LK.getScore() + corn.scoreValue);
scoreText.setText(LK.getScore().toString());
LK.getSound('cornCollect').play();
// Add collection effect
tween(corn, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
corn.destroy();
}
});
cornDrops.splice(c, 1);
continue;
}
// Remove corn that's been on screen too long (30 seconds)
if (corn.lifeTime === undefined) corn.lifeTime = 0;
corn.lifeTime++;
if (corn.lifeTime > 1800) {
// 30 seconds at 60fps
corn.destroy();
cornDrops.splice(c, 1);
}
}
// Update UI
healthText.setText('Health: ' + player.health + '/' + player.maxHealth);
}; ===================================================================
--- original.js
+++ change.js
@@ -23,9 +23,24 @@
self.waveAttackRange = 400; // Longer range for wave attacks
self.waveAttackRate = 180; // 3 seconds between wave attacks
// Visual effect for claw attack
self.clawEffect = null;
+ // Animation properties
+ self.animationOffset = Math.random() * Math.PI * 2;
+ self.breathingSpeed = 0.08;
+ self.intimidationFactor = 1;
self.update = function () {
+ // Add intimidating breathing animation
+ var breathe = Math.sin(LK.ticks * self.breathingSpeed + self.animationOffset) * 0.15;
+ graphics.scaleX = self.intimidationFactor + breathe;
+ graphics.scaleY = self.intimidationFactor + breathe * 0.7;
+ // Add slight rotation sway
+ graphics.rotation = Math.sin(LK.ticks * 0.05 + self.animationOffset) * 0.1;
+ // Add color pulsing for menacing effect
+ var pulseIntensity = Math.sin(LK.ticks * 0.1 + self.animationOffset) * 0.3 + 0.7;
+ if (graphics.tint === 0xFFFFFF || graphics.tint === undefined) {
+ graphics.tint = 0xFF0000;
+ }
if (player) {
var angle = Math.atan2(player.y - self.y, player.x - self.x);
var distanceToPlayer = Math.sqrt(Math.pow(player.x - self.x, 2) + Math.pow(player.y - self.y, 2));
// Move towards player with increased speed
@@ -180,9 +195,17 @@
self.health = 50;
self.speed = 1.5;
self.damage = 20;
self.waveNumber = currentWave;
+ // Animation properties
+ self.animationOffset = Math.random() * Math.PI * 2;
+ self.rotationSpeed = 0.02 + Math.random() * 0.02;
self.update = function () {
+ // Add menacing wobble animation
+ graphics.rotation += self.rotationSpeed;
+ var wobble = Math.sin(LK.ticks * 0.2 + self.animationOffset) * 0.1;
+ graphics.scaleX = 1 + wobble;
+ graphics.scaleY = 1 - wobble * 0.5;
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;
@@ -242,9 +265,21 @@
self.maxHealth = 100;
self.speed = 4;
self.shootCooldown = 0;
self.shootRate = 20; // frames between shots
+ // Animation properties
+ self.animationOffset = Math.random() * Math.PI * 2;
+ self.baseY = 0;
+ self.isAnimating = false;
self.update = function () {
+ // Initialize base position for floating animation
+ if (self.baseY === 0) self.baseY = self.y;
+ // Add subtle floating animation
+ graphics.y = Math.sin(LK.ticks * 0.15 + self.animationOffset) * 3;
+ // Add subtle scale pulsing
+ var scalePulse = 1 + Math.sin(LK.ticks * 0.1 + self.animationOffset) * 0.05;
+ graphics.scaleX = scalePulse;
+ graphics.scaleY = scalePulse;
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
// Auto-shoot at nearest enemy
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