User prompt
thats on top of gold now, put the wave at the bottom instead
User prompt
move the wave text to inside the right bar
User prompt
Please fix the bug: 'LK.getMusic is not a function' in or related to this line: 'if (waveStartText.alpha <= 0) {' Line Number: 563
User prompt
Please fix the bug: 'LK.getMusic is not a function' in or related to this line: 'LK.getMusic('background').play();' Line Number: 528
User prompt
Please fix the bug: 'self.createUpgradeButton is not a function' in or related to this line: 'var buttons = {' Line Number: 330
User prompt
Please fix the bug: 'LK.Sprite is not a constructor' in or related to this line: 'background = new LK.Sprite('background');' Line Number: 573
User prompt
Please fix the bug: 'LK.getMusic is not a function' in or related to this line: 'LK.getMusic('background').play();' Line Number: 571
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'LK.getMusic is not a function' in or related to this line: 'if (waveStartText.alpha <= 0) {' Line Number: 560
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'bonusText is not defined' in or related to this line: 'if (bonusText) {' Line Number: 548
User prompt
Please fix the bug: 'waveCompleteText is not defined' in or related to this line: 'if (waveCompleteText) {' Line Number: 544
User prompt
the wave completed text from last round should get removed when have starts
User prompt
the wave completed text should get removed after the wave end
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'var dx = tower.x - self.x;' Line Number: 449
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < zombies.length; i++) {' Line Number: 128
Code edit (1 edits merged)
Please save this source code
Initial prompt
Horde Defence
/**** * Classes ****/ // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.update = function () { self.y += self.speed; if (self.y < -50) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Tower class var Tower = Container.expand(function () { var self = Container.call(this); var towerGraphics = self.attachAsset('tower', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.upgradeLevel = 1; self.upgrade = function () { if (self.upgradeLevel < 5) { self.upgradeLevel++; // Increase tower capabilities } }; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { LK.showGameOver(); } }; }); // Zombie class var Zombie = Container.expand(function () { var self = Container.call(this); var zombieGraphics = self.attachAsset('zombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.health = 20; self.update = function () { self.y += self.speed; if (self.y > 2732) { tower.takeDamage(10); self.destroy(); } }; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var tower = game.addChild(new Tower()); tower.x = 2048 / 2; tower.y = 2732 - 200; var bullets = []; var zombies = []; var lastZombieSpawn = 0; game.update = function () { // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; bullet.update(); for (var j = zombies.length - 1; j >= 0; j--) { var zombie = zombies[j]; if (bullet.intersects(zombie)) { zombie.takeDamage(10); bullet.destroy(); bullets.splice(i, 1); break; } } } // Update zombies for (var i = zombies.length - 1; i >= 0; i--) { var zombie = zombies[i]; zombie.update(); } // Spawn new zombies if (LK.ticks - lastZombieSpawn > 60) { var newZombie = new Zombie(); newZombie.x = Math.random() * 2048; newZombie.y = -50; zombies.push(newZombie); game.addChild(newZombie); lastZombieSpawn = LK.ticks; } }; game.down = function (x, y, obj) { var newBullet = new Bullet(); newBullet.x = tower.x; newBullet.y = tower.y; bullets.push(newBullet); game.addChild(newBullet); };
/****
* Classes
****/
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -10;
self.update = function () {
self.y += self.speed;
if (self.y < -50) {
self.destroy();
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Tower class
var Tower = Container.expand(function () {
var self = Container.call(this);
var towerGraphics = self.attachAsset('tower', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.upgradeLevel = 1;
self.upgrade = function () {
if (self.upgradeLevel < 5) {
self.upgradeLevel++;
// Increase tower capabilities
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
LK.showGameOver();
}
};
});
// Zombie class
var Zombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.health = 20;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
tower.takeDamage(10);
self.destroy();
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var tower = game.addChild(new Tower());
tower.x = 2048 / 2;
tower.y = 2732 - 200;
var bullets = [];
var zombies = [];
var lastZombieSpawn = 0;
game.update = function () {
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
bullet.update();
for (var j = zombies.length - 1; j >= 0; j--) {
var zombie = zombies[j];
if (bullet.intersects(zombie)) {
zombie.takeDamage(10);
bullet.destroy();
bullets.splice(i, 1);
break;
}
}
}
// Update zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var zombie = zombies[i];
zombie.update();
}
// Spawn new zombies
if (LK.ticks - lastZombieSpawn > 60) {
var newZombie = new Zombie();
newZombie.x = Math.random() * 2048;
newZombie.y = -50;
zombies.push(newZombie);
game.addChild(newZombie);
lastZombieSpawn = LK.ticks;
}
};
game.down = function (x, y, obj) {
var newBullet = new Bullet();
newBullet.x = tower.x;
newBullet.y = tower.y;
bullets.push(newBullet);
game.addChild(newBullet);
};