User prompt
Add a Canadian Goose in treasure hoarder outfit wtih ability to make a fake emden goose to charm Emden Goose ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add a Pyro Catalyst Canadian Goose and he can summon fire magic! ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add pie flavour assets with effects on enemies and healing on Canadian Geese ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add a Pie Shooter Canadian Goose armed with a Spoon shooting different flavoured piece of pie into Emden Geese and she can heal Canadian Geese ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
add anti virus Goose ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fix errors PLS!
User prompt
Add main menu
User prompt
Add a new bros in to the game: Canadian Geese: Sun Shooter - Canadian Goose in Sun Warrior Outfit with Sun Crossbow and Sun Arrows (Type of Attack: Shoot Attack) Moonlight Sleeper - Canadian Goose in Moonlight Magician Outfit with Magic Staff of Moon and Moonlight Magic (Type of Attack: Moonlight Magic Shoot!) New Enemies: Red Moon Treasure Hoarder Emden Goose with Red Moon Magic Staff and Blue Sun Emden Goose with Long Sword) (In the Sun World Sun Shooter bro is strong and weak in Mua World and Moonlight bro is Strong in Mua world but weak in Sun world!) (2 New worlds: Sun World - Episode 2 and Mua World - Episode 3!) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (5 edits merged)
Please save this source code
User prompt
Pls make unlimited money to buy geese! (and new enemy: treasure hoarder emden goose "Hydro Arrow" with blue hydro battle bow)
User prompt
Time to add new canadian goose: A Canadian goose in electro purple armor with electro purple hammer! (this bro can stun emden geese by hammer) (in game he named Hammer Goose) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'canadianBtn.style.fill = "#FFD700";' Line Number: 460
User prompt
Add a Ameno Emden Potioneer Emden Goose Enemy and fix the errors
Code edit (1 edits merged)
Please save this source code
User prompt
Goose Guard: Ice Defense
Initial prompt
Make a Tower Defense game but all towers and player are canadian geese! (this game have a special Canadian goose: Ice Magic Canadian Goose with his ability: Canadian goose freeze ability!) (enemies are treasure hoarder Emden geese) (no bosses!)
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AmenoEmdenGoose = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('amenoGoose', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.speed = 1.2;
self.pathIndex = 0;
self.reward = 20;
self.frozen = false;
self.freezeTimer = 0;
self.destroyed = false;
self.potionTimer = 0;
self.potionRate = 240; // 4 seconds at 60fps
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff1e00, 200);
if (self.health <= 0) {
resources += self.reward;
updateResourceDisplay();
LK.getSound('defeat').play();
self.destroyed = true;
self.destroy();
}
};
self.freeze = function (duration) {
self.frozen = true;
self.freezeTimer = duration;
graphics.tint = 0xAADDFF;
var iceEffect = new IceEffect();
iceEffect.x = self.x;
iceEffect.y = self.y;
game.addChild(iceEffect);
};
self.stunned = false;
self.stunTimer = 0;
self.stun = function (duration) {
self.stunned = true;
self.stunTimer = duration;
graphics.tint = 0x9932CC; // Purple tint for stun
var stunEffect = new StunEffect();
stunEffect.x = self.x;
stunEffect.y = self.y;
game.addChild(stunEffect);
};
self.throwPotion = function () {
var nearestTower = findNearestTower(self.x, self.y, 200);
if (nearestTower) {
var potion = new PoisonPotion();
potion.x = self.x;
potion.y = self.y;
potion.target = nearestTower;
potions.push(potion);
game.addChild(potion);
LK.getSound('potion').play();
}
};
self.update = function () {
if (self.freezeTimer > 0) {
self.freezeTimer--;
if (self.freezeTimer <= 0) {
self.frozen = false;
graphics.tint = 0xFFFFFF;
}
}
// Handle stun timer
if (self.stunTimer > 0) {
self.stunTimer--;
if (self.stunTimer <= 0) {
self.stunned = false;
graphics.tint = 0xFFFFFF;
}
}
// Potion throwing ability
self.potionTimer++;
if (self.potionTimer >= self.potionRate && !self.frozen && !self.stunned) {
self.throwPotion();
self.potionTimer = 0;
}
if (!self.frozen && !self.stunned && self.pathIndex < pathPoints.length - 1) {
var target = pathPoints[self.pathIndex + 1];
var dx = target.x - self.x;
var dy = target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 10) {
self.pathIndex++;
if (self.pathIndex >= pathPoints.length - 1) {
lives--;
updateLivesDisplay();
if (lives <= 0) {
LK.showGameOver();
}
self.destroyed = true;
self.destroy();
return;
}
} else {
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
}
}
};
return self;
});
var CanadianGoose = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('canadianGoose', {
anchorX: 0.5,
anchorY: 0.5
});
self.range = 150;
self.damage = 25;
self.fireRate = 60; // 1 second at 60fps
self.fireTimer = 0;
self.cost = 50;
self.disabled = false;
self.disableTimer = 0;
self.update = function () {
// Handle disable timer
if (self.disableTimer > 0) {
self.disableTimer--;
if (self.disableTimer <= 0) {
self.disabled = false;
}
}
if (!self.disabled) {
self.fireTimer++;
if (self.fireTimer >= self.fireRate) {
var target = findNearestEnemy(self.x, self.y, self.range);
if (target) {
var projectile = new Projectile();
projectile.x = self.x;
projectile.y = self.y;
projectile.target = target;
projectile.damage = self.damage;
projectiles.push(projectile);
game.addChild(projectile);
LK.getSound('honk').play();
self.fireTimer = 0;
}
}
}
};
return self;
});
var EmdenGoose = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('emdenGoose', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.speed = 1.5;
self.pathIndex = 0;
self.reward = 10;
self.frozen = false;
self.freezeTimer = 0;
self.destroyed = false;
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xFF0000, 200);
if (self.health <= 0) {
resources += self.reward;
updateResourceDisplay();
LK.getSound('defeat').play();
self.destroyed = true;
self.destroy();
}
};
self.freeze = function (duration) {
self.frozen = true;
self.freezeTimer = duration;
graphics.tint = 0xAADDFF;
var iceEffect = new IceEffect();
iceEffect.x = self.x;
iceEffect.y = self.y;
game.addChild(iceEffect);
};
self.stunned = false;
self.stunTimer = 0;
self.stun = function (duration) {
self.stunned = true;
self.stunTimer = duration;
graphics.tint = 0x9932CC; // Purple tint for stun
var stunEffect = new StunEffect();
stunEffect.x = self.x;
stunEffect.y = self.y;
game.addChild(stunEffect);
};
self.update = function () {
if (self.freezeTimer > 0) {
self.freezeTimer--;
if (self.freezeTimer <= 0) {
self.frozen = false;
graphics.tint = 0xFFFFFF;
}
}
// Handle stun timer
if (self.stunTimer > 0) {
self.stunTimer--;
if (self.stunTimer <= 0) {
self.stunned = false;
graphics.tint = 0xFFFFFF;
}
}
if (!self.frozen && !self.stunned && self.pathIndex < pathPoints.length - 1) {
var target = pathPoints[self.pathIndex + 1];
var dx = target.x - self.x;
var dy = target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 10) {
self.pathIndex++;
if (self.pathIndex >= pathPoints.length - 1) {
lives--;
updateLivesDisplay();
if (lives <= 0) {
LK.showGameOver();
}
self.destroyed = true;
self.destroy();
return;
}
} else {
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
}
}
};
return self;
});
var HammerGoose = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('hammerGoose', {
anchorX: 0.5,
anchorY: 0.5
});
graphics.tint = 0x9932CC; // Electro purple color
self.range = 100;
self.stunDuration = 180; // 3 seconds at 60fps
self.fireRate = 90; // 1.5 seconds at 60fps
self.fireTimer = 0;
self.cost = 120;
self.disabled = false;
self.disableTimer = 0;
self.update = function () {
// Handle disable timer
if (self.disableTimer > 0) {
self.disableTimer--;
if (self.disableTimer <= 0) {
self.disabled = false;
}
}
if (!self.disabled) {
self.fireTimer++;
if (self.fireTimer >= self.fireRate) {
var target = findNearestEnemy(self.x, self.y, self.range);
if (target && !target.stunned) {
// Hammer swing animation
tween(graphics, {
rotation: graphics.rotation + Math.PI / 4
}, {
duration: 150,
easing: tween.easeOut
});
tween(graphics, {
rotation: graphics.rotation
}, {
duration: 150,
easing: tween.easeIn
});
// Stun the enemy
target.stun(self.stunDuration);
LK.getSound('hammer').play();
self.fireTimer = 0;
}
}
}
};
return self;
});
var HydroArrow = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('projectile', {
anchorX: 0.5,
anchorY: 0.5
});
graphics.tint = 0x0066CC; // Blue hydro color
self.speed = 7;
self.target = null;
self.destroyed = false;
self.update = function () {
if (self.target && !self.target.destroyed) {
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 25) {
// Disable tower for 4 seconds and deal damage
self.target.disabled = true;
self.target.disableTimer = 240; // 4 seconds at 60fps
LK.effects.flashObject(self.target, 0x0066CC, 600);
self.destroyed = true;
self.destroy();
return;
}
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
} else {
self.destroyed = true;
self.destroy();
}
};
return self;
});
var HydroArrowEmdenGoose = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('hydroGoose', {
anchorX: 0.5,
anchorY: 0.5
});
graphics.tint = 0x0066CC; // Blue hydro color
self.health = 150;
self.maxHealth = 150;
self.speed = 1.0;
self.pathIndex = 0;
self.reward = 30;
self.frozen = false;
self.freezeTimer = 0;
self.destroyed = false;
self.arrowTimer = 0;
self.arrowRate = 180; // 3 seconds at 60fps
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff1e00, 200);
if (self.health <= 0) {
resources += self.reward;
updateResourceDisplay();
LK.getSound('defeat').play();
self.destroyed = true;
self.destroy();
}
};
self.freeze = function (duration) {
self.frozen = true;
self.freezeTimer = duration;
graphics.tint = 0xAADDFF;
var iceEffect = new IceEffect();
iceEffect.x = self.x;
iceEffect.y = self.y;
game.addChild(iceEffect);
};
self.stunned = false;
self.stunTimer = 0;
self.stun = function (duration) {
self.stunned = true;
self.stunTimer = duration;
graphics.tint = 0x9932CC; // Purple tint for stun
var stunEffect = new StunEffect();
stunEffect.x = self.x;
stunEffect.y = self.y;
game.addChild(stunEffect);
};
self.shootArrow = function () {
var nearestTower = findNearestTower(self.x, self.y, 250);
if (nearestTower) {
var arrow = new HydroArrow();
arrow.x = self.x;
arrow.y = self.y;
arrow.target = nearestTower;
potions.push(arrow);
game.addChild(arrow);
LK.getSound('hydroArrow').play();
}
};
self.update = function () {
if (self.freezeTimer > 0) {
self.freezeTimer--;
if (self.freezeTimer <= 0) {
self.frozen = false;
graphics.tint = 0x0066CC; // Return to blue hydro color
}
}
// Handle stun timer
if (self.stunTimer > 0) {
self.stunTimer--;
if (self.stunTimer <= 0) {
self.stunned = false;
graphics.tint = 0x0066CC; // Return to blue hydro color
}
}
// Hydro arrow shooting ability
self.arrowTimer++;
if (self.arrowTimer >= self.arrowRate && !self.frozen && !self.stunned) {
self.shootArrow();
self.arrowTimer = 0;
}
if (!self.frozen && !self.stunned && self.pathIndex < pathPoints.length - 1) {
var target = pathPoints[self.pathIndex + 1];
var dx = target.x - self.x;
var dy = target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 10) {
self.pathIndex++;
if (self.pathIndex >= pathPoints.length - 1) {
lives--;
updateLivesDisplay();
if (lives <= 0) {
LK.showGameOver();
}
self.destroyed = true;
self.destroy();
return;
}
} else {
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
}
}
};
return self;
});
var IceEffect = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('iceEffect', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.6
});
self.duration = 180; // 3 seconds at 60fps
self.timer = 0;
self.update = function () {
self.timer++;
graphics.rotation += 0.1;
if (self.timer >= self.duration) {
self.destroy();
}
};
return self;
});
var IceGoose = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('iceGoose', {
anchorX: 0.5,
anchorY: 0.5
});
self.range = 120;
self.freezeDuration = 120; // 2 seconds at 60fps
self.fireRate = 180; // 3 seconds at 60fps
self.fireTimer = 0;
self.cost = 80;
self.disabled = false;
self.disableTimer = 0;
self.update = function () {
// Handle disable timer
if (self.disableTimer > 0) {
self.disableTimer--;
if (self.disableTimer <= 0) {
self.disabled = false;
}
}
if (!self.disabled) {
self.fireTimer++;
if (self.fireTimer >= self.fireRate) {
var target = findNearestEnemy(self.x, self.y, self.range);
if (target && !target.frozen) {
target.freeze(self.freezeDuration);
LK.getSound('freeze').play();
self.fireTimer = 0;
}
}
}
};
return self;
});
var PoisonPotion = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('projectile', {
anchorX: 0.5,
anchorY: 0.5
});
graphics.tint = 0x9932CC; // Purple color for poison
self.speed = 6;
self.target = null;
self.destroyed = false;
self.update = function () {
if (self.target && !self.target.destroyed) {
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 25) {
// Disable tower for 3 seconds
self.target.disabled = true;
self.target.disableTimer = 180; // 3 seconds at 60fps
LK.effects.flashObject(self.target, 0x9932CC, 500);
self.destroyed = true;
self.destroy();
return;
}
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
} else {
self.destroyed = true;
self.destroy();
}
};
return self;
});
var Projectile = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('projectile', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.target = null;
self.damage = 25;
self.update = function () {
if (self.target && !self.target.destroyed) {
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 20) {
self.target.takeDamage(self.damage);
self.destroy();
return;
}
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
} else {
self.destroy();
}
};
return self;
});
var StunEffect = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('stunEffect', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8
});
graphics.tint = 0x9932CC; // Purple color for stun effect
self.duration = 120; // 2 seconds at 60fps
self.timer = 0;
self.update = function () {
self.timer++;
graphics.rotation += 0.15;
graphics.scaleX = 1 + Math.sin(self.timer * 0.2) * 0.1;
graphics.scaleY = 1 + Math.sin(self.timer * 0.2) * 0.1;
if (self.timer >= self.duration) {
self.destroy();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22
});
/****
* Game Code
****/
// Game variables
var resources = 999999;
var lives = 20;
var wave = 1;
var enemies = [];
var towers = [];
var projectiles = [];
var potions = [];
var waveTimer = 0;
var waveDelay = 300; // 5 seconds between waves
var enemiesPerWave = 5;
var selectedTowerType = 'canadian';
// Path points for enemies to follow
var pathPoints = [{
x: 0,
y: 400
}, {
x: 300,
y: 400
}, {
x: 300,
y: 800
}, {
x: 700,
y: 800
}, {
x: 700,
y: 1200
}, {
x: 1100,
y: 1200
}, {
x: 1100,
y: 1600
}, {
x: 1500,
y: 1600
}, {
x: 1500,
y: 2000
}, {
x: 2048,
y: 2000
}];
// Create path visuals
for (var i = 0; i < pathPoints.length - 1; i++) {
var start = pathPoints[i];
var end = pathPoints[i + 1];
var segments = Math.ceil(Math.sqrt((end.x - start.x) * (end.x - start.x) + (end.y - start.y) * (end.y - start.y)) / 100);
for (var j = 0; j < segments; j++) {
var t = j / segments;
var pathSegment = game.addChild(LK.getAsset('path', {
anchorX: 0.5,
anchorY: 0.5,
x: start.x + (end.x - start.x) * t,
y: start.y + (end.y - start.y) * t,
alpha: 0.3
}));
}
}
// Create treasure at end
var treasure = game.addChild(LK.getAsset('treasure', {
anchorX: 0.5,
anchorY: 0.5,
x: pathPoints[pathPoints.length - 1].x - 100,
y: pathPoints[pathPoints.length - 1].y
}));
// UI Elements
var resourceTxt = new Text2('Resources: ' + resources, {
size: 60,
fill: 0xFFFFFF
});
resourceTxt.anchor.set(0, 0);
LK.gui.topRight.addChild(resourceTxt);
resourceTxt.x = -300;
resourceTxt.y = 50;
var livesTxt = new Text2('Lives: ' + lives, {
size: 60,
fill: 0xFFFFFF
});
livesTxt.anchor.set(0, 0);
LK.gui.topRight.addChild(livesTxt);
livesTxt.x = -300;
livesTxt.y = 120;
var waveTxt = new Text2('Wave: ' + wave, {
size: 60,
fill: 0xFFFFFF
});
waveTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(waveTxt);
waveTxt.x = 120;
waveTxt.y = 50;
// Tower selection buttons
var canadianBtn = new Text2('Canadian Goose (50)', {
size: 50,
fill: 0x8B4513
});
canadianBtn.anchor.set(0.5, 0);
LK.gui.bottom.addChild(canadianBtn);
canadianBtn.y = -200;
canadianBtn.x = -200;
var iceBtn = new Text2('Ice Goose (80)', {
size: 50,
fill: 0x87CEEB
});
iceBtn.anchor.set(0.5, 0);
LK.gui.bottom.addChild(iceBtn);
iceBtn.y = -200;
iceBtn.x = 0;
var hammerBtn = new Text2('Hammer Goose (120)', {
size: 50,
fill: 0x9932CC
});
hammerBtn.anchor.set(0.5, 0);
LK.gui.bottom.addChild(hammerBtn);
hammerBtn.y = -200;
hammerBtn.x = 400;
// Button interactions
canadianBtn.down = function () {
selectedTowerType = 'canadian';
canadianBtn.fill = 0xFFD700;
iceBtn.fill = 0x87CEEB;
hammerBtn.fill = 0x9932CC;
};
iceBtn.down = function () {
selectedTowerType = 'ice';
iceBtn.fill = 0xFFD700;
canadianBtn.fill = 0x8B4513;
hammerBtn.fill = 0x9932CC;
};
hammerBtn.down = function () {
selectedTowerType = 'hammer';
hammerBtn.fill = 0xFFD700;
canadianBtn.fill = 0x8B4513;
iceBtn.fill = 0x87CEEB;
};
// Helper functions
function updateResourceDisplay() {
resourceTxt.setText('Resources: ' + resources);
}
function updateLivesDisplay() {
livesTxt.setText('Lives: ' + lives);
}
function updateWaveDisplay() {
waveTxt.setText('Wave: ' + wave);
}
function findNearestEnemy(x, y, range) {
var nearest = null;
var nearestDistance = range;
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
if (!enemy.destroyed) {
var dx = enemy.x - x;
var dy = enemy.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearest = enemy;
nearestDistance = distance;
}
}
}
return nearest;
}
function findNearestTower(x, y, range) {
var nearest = null;
var nearestDistance = range;
for (var i = 0; i < towers.length; i++) {
var tower = towers[i];
if (!tower.destroyed) {
var dx = tower.x - x;
var dy = tower.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearest = tower;
nearestDistance = distance;
}
}
}
return nearest;
}
function spawnWave() {
for (var i = 0; i < enemiesPerWave + Math.floor(wave / 3); i++) {
LK.setTimeout(function () {
var enemy;
var rand = Math.random();
// 20% chance to spawn Hydro Arrow Emden after wave 3
if (wave >= 3 && rand < 0.2) {
enemy = new HydroArrowEmdenGoose();
// 25% chance to spawn Ameno Emden Potioneer after wave 2
} else if (wave >= 2 && rand < 0.45) {
enemy = new AmenoEmdenGoose();
} else {
enemy = new EmdenGoose();
}
enemy.x = pathPoints[0].x;
enemy.y = pathPoints[0].y;
enemy.health = enemy.maxHealth + (wave - 1) * 20;
enemy.maxHealth = enemy.health;
enemies.push(enemy);
game.addChild(enemy);
}, i * 1000);
}
}
// Game interaction
game.down = function (x, y, obj) {
// Check if clicking on path (don't allow tower placement)
var onPath = false;
for (var i = 0; i < pathPoints.length - 1; i++) {
var start = pathPoints[i];
var end = pathPoints[i + 1];
var dx = end.x - start.x;
var dy = end.y - start.y;
var length = Math.sqrt(dx * dx + dy * dy);
var nx = dx / length;
var ny = dy / length;
var px = x - start.x;
var py = y - start.y;
var dot = px * nx + py * ny;
if (dot >= 0 && dot <= length) {
var distance = Math.abs(px * ny - py * nx);
if (distance < 60) {
onPath = true;
break;
}
}
}
if (!onPath) {
var tower = null;
var cost = 0;
if (selectedTowerType === 'canadian') {
tower = new CanadianGoose();
cost = tower.cost;
} else if (selectedTowerType === 'ice') {
tower = new IceGoose();
cost = tower.cost;
} else if (selectedTowerType === 'hammer') {
tower = new HammerGoose();
cost = tower.cost;
}
if (tower && resources >= cost) {
tower.x = x;
tower.y = y;
towers.push(tower);
game.addChild(tower);
resources -= cost;
updateResourceDisplay();
}
}
};
// Initialize first wave
spawnWave();
// Main game loop
game.update = function () {
waveTimer++;
// Clean up destroyed enemies
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i].destroyed) {
enemies.splice(i, 1);
}
}
// Clean up destroyed projectiles
for (var i = projectiles.length - 1; i >= 0; i--) {
if (projectiles[i].destroyed) {
projectiles.splice(i, 1);
}
}
// Clean up destroyed potions
for (var i = potions.length - 1; i >= 0; i--) {
if (potions[i].destroyed) {
potions.splice(i, 1);
}
}
// Check if wave is complete and spawn next wave
if (enemies.length === 0 && waveTimer >= waveDelay) {
wave++;
updateWaveDisplay();
waveTimer = 0;
spawnWave();
// Win condition
if (wave > 10) {
LK.showYouWin();
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -290,8 +290,150 @@
}
};
return self;
});
+var HydroArrow = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('projectile', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ graphics.tint = 0x0066CC; // Blue hydro color
+ self.speed = 7;
+ self.target = null;
+ self.destroyed = false;
+ self.update = function () {
+ if (self.target && !self.target.destroyed) {
+ var dx = self.target.x - self.x;
+ var dy = self.target.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 25) {
+ // Disable tower for 4 seconds and deal damage
+ self.target.disabled = true;
+ self.target.disableTimer = 240; // 4 seconds at 60fps
+ LK.effects.flashObject(self.target, 0x0066CC, 600);
+ self.destroyed = true;
+ self.destroy();
+ return;
+ }
+ var angle = Math.atan2(dy, dx);
+ self.x += Math.cos(angle) * self.speed;
+ self.y += Math.sin(angle) * self.speed;
+ } else {
+ self.destroyed = true;
+ self.destroy();
+ }
+ };
+ return self;
+});
+var HydroArrowEmdenGoose = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('hydroGoose', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ graphics.tint = 0x0066CC; // Blue hydro color
+ self.health = 150;
+ self.maxHealth = 150;
+ self.speed = 1.0;
+ self.pathIndex = 0;
+ self.reward = 30;
+ self.frozen = false;
+ self.freezeTimer = 0;
+ self.destroyed = false;
+ self.arrowTimer = 0;
+ self.arrowRate = 180; // 3 seconds at 60fps
+ self.takeDamage = function (damage) {
+ self.health -= damage;
+ LK.effects.flashObject(self, 0xff1e00, 200);
+ if (self.health <= 0) {
+ resources += self.reward;
+ updateResourceDisplay();
+ LK.getSound('defeat').play();
+ self.destroyed = true;
+ self.destroy();
+ }
+ };
+ self.freeze = function (duration) {
+ self.frozen = true;
+ self.freezeTimer = duration;
+ graphics.tint = 0xAADDFF;
+ var iceEffect = new IceEffect();
+ iceEffect.x = self.x;
+ iceEffect.y = self.y;
+ game.addChild(iceEffect);
+ };
+ self.stunned = false;
+ self.stunTimer = 0;
+ self.stun = function (duration) {
+ self.stunned = true;
+ self.stunTimer = duration;
+ graphics.tint = 0x9932CC; // Purple tint for stun
+ var stunEffect = new StunEffect();
+ stunEffect.x = self.x;
+ stunEffect.y = self.y;
+ game.addChild(stunEffect);
+ };
+ self.shootArrow = function () {
+ var nearestTower = findNearestTower(self.x, self.y, 250);
+ if (nearestTower) {
+ var arrow = new HydroArrow();
+ arrow.x = self.x;
+ arrow.y = self.y;
+ arrow.target = nearestTower;
+ potions.push(arrow);
+ game.addChild(arrow);
+ LK.getSound('hydroArrow').play();
+ }
+ };
+ self.update = function () {
+ if (self.freezeTimer > 0) {
+ self.freezeTimer--;
+ if (self.freezeTimer <= 0) {
+ self.frozen = false;
+ graphics.tint = 0x0066CC; // Return to blue hydro color
+ }
+ }
+ // Handle stun timer
+ if (self.stunTimer > 0) {
+ self.stunTimer--;
+ if (self.stunTimer <= 0) {
+ self.stunned = false;
+ graphics.tint = 0x0066CC; // Return to blue hydro color
+ }
+ }
+ // Hydro arrow shooting ability
+ self.arrowTimer++;
+ if (self.arrowTimer >= self.arrowRate && !self.frozen && !self.stunned) {
+ self.shootArrow();
+ self.arrowTimer = 0;
+ }
+ if (!self.frozen && !self.stunned && self.pathIndex < pathPoints.length - 1) {
+ var target = pathPoints[self.pathIndex + 1];
+ var dx = target.x - self.x;
+ var dy = target.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 10) {
+ self.pathIndex++;
+ if (self.pathIndex >= pathPoints.length - 1) {
+ lives--;
+ updateLivesDisplay();
+ if (lives <= 0) {
+ LK.showGameOver();
+ }
+ self.destroyed = true;
+ self.destroy();
+ return;
+ }
+ } else {
+ var angle = Math.atan2(dy, dx);
+ self.x += Math.cos(angle) * self.speed;
+ self.y += Math.sin(angle) * self.speed;
+ }
+ }
+ };
+ return self;
+});
var IceEffect = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('iceEffect', {
anchorX: 0.5,
@@ -438,9 +580,9 @@
/****
* Game Code
****/
// Game variables
-var resources = 150;
+var resources = 999999;
var lives = 20;
var wave = 1;
var enemies = [];
var towers = [];
@@ -621,10 +763,14 @@
function spawnWave() {
for (var i = 0; i < enemiesPerWave + Math.floor(wave / 3); i++) {
LK.setTimeout(function () {
var enemy;
- // 30% chance to spawn Ameno Emden Potioneer after wave 2
- if (wave >= 2 && Math.random() < 0.3) {
+ var rand = Math.random();
+ // 20% chance to spawn Hydro Arrow Emden after wave 3
+ if (wave >= 3 && rand < 0.2) {
+ enemy = new HydroArrowEmdenGoose();
+ // 25% chance to spawn Ameno Emden Potioneer after wave 2
+ } else if (wave >= 2 && rand < 0.45) {
enemy = new AmenoEmdenGoose();
} else {
enemy = new EmdenGoose();
}
Canadian Goose in robe with sword. In-Game asset. 2d. High contrast. No shadows
Emden Goose in Outfit of Treasure Hoarders. In-Game asset. 2d. High contrast. No shadows
A Canadian Goose in Magic Ice Mage Outfit armed with a magic ice staff. In-Game asset. 2d. High contrast. No shadows
Emden Goose in Cyan Outfit of Treasure Hoarders armed with cyan anemo potion. In-Game asset. 2d. High contrast. No shadows
Ice magic effect. In-Game asset. 2d. High contrast. No shadows
A emden goose in blue treasure hoarders outfit with blue hydro battle bow. In-Game asset. 2d. High contrast. No shadows
Treasure with canadian geese as guard No text on image!!. In-Game asset. 2d. High contrast. No shadows
A Canadian goose in armor armed electro purple battle hammer.. In-Game asset. 2d. No shadows
A Canadian Goose in Moon Mage Outfit with Moonlight Magic Staff. In-Game asset. 2d. High contrast. No shadows
Canadian Goose in Sun Warrior Outfit with Magic Sun Crossbow. In-Game asset. 2d. High contrast. No shadows
An Emden Goose in Blue Sun Treasure Hoarder Outfit with Blue Sun Long Sword. In-Game asset. 2d. High contrast. No shadows
A Emden Goose in Treasure Hoarder Red Moon Mage Outfit with Red Moon Magic Staff. In-Game asset. 2d. High contrast. No shadows
Purple Stun Aura, No text on image!. In-Game asset. 2d. High contrast. No shadows
A Canadian Goose in Green Glowing Anti Virus Outfit Armed with anti virus magic. In-Game asset. 2d
A Canadian Goose in maid chef outfit armed with spoon with tangerine pie on it. In-Game asset. 2d. High contrast. No shadows
Cherry pie with pink fire aura. In-Game asset. 2d. High contrast. No shadows
apple pie with green aura. In-Game asset. 2d. High contrast. No shadows
blueberry pie with frost aura. In-Game asset. 2d. High contrast. No shadows
A Canadian Goose in Pyro Mage outfit holding a pyro catalyst. In-Game asset. 2d. High contrast. No shadows
Canadian Goose in treasure hoarder outfit with claymore. In-Game asset. 2d. High contrast. No shadows