User prompt
fireballprojectiles should check in their update function if they collide with an enemy, and deal damage to it and destroy itself
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: hero is undefined' in this line: 'hero.rotation += rotationSpeed;' Line Number: 82
User prompt
add a new weapon type called FireballWeapon that slowly rotates, firing FireballProjectiles in the direction it's facing.
Code edit (13 edits merged)
Please save this source code
User prompt
RangedEnemies scale back and forth slightly during their update
User prompt
ranged enemies flash black when they attack
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Add a RangedEnemy class which moves towards the hero, periodically shooting EnemyProjectiles towards the hero when it's within 500 range
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: midgroundContainer is not defined' in this line: 'var enemy = new BasicEnemy(midgroundContainer, x, y, {' Line Number: 95
User prompt
make an EnemySpawner class that handles the spawning of enemies instead of the tick event
Code edit (1 edits merged)
Please save this source code
User prompt
countdown timer should continue counting down even after reaching zero
User prompt
when the countdowntimer reaches zero, perform a once-off update that changes the text to red
Code edit (8 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: bool is not defined' in this line: 'if (bool === 'Health') {' Line Number: 862
Code edit (5 edits merged)
Please save this source code
User prompt
healing pickups first check if the hero is at max health already before applying the heal and destroying itself
User prompt
Fix Bug: 'ReferenceError: health is not defined' in this line: 'if (health <= 0) {' Line Number: 684
User prompt
change the hero's `var health` and `var healthMax` to `self.health` and `self.healthMax` and update any references to these variables found within the hero class
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: sqrt is not defined' in this line: 'var distance = sqrt(distance);' Line Number: 317
Code edit (6 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -209,17 +209,20 @@
var self = Container.call(this);
var availableBoons = Object.keys(boons).filter(function (boon) {
return boons[boon] < 3;
});
- if (!availableBoons.length) {
- self.destroy();
- callback();
- }
var selectedBoons = [];
- while (selectedBoons.length < 3 && availableBoons.length > 0) {
- var boonIndex = Math.floor(Math.random() * availableBoons.length);
- selectedBoons.push(availableBoons.splice(boonIndex, 1)[0]);
+ if (availableBoons.length <= 3) {
+ selectedBoons = availableBoons;
+ } else {
+ while (selectedBoons.length < 3 && availableBoons.length > 0) {
+ var boonIndex = Math.floor(Math.random() * availableBoons.length);
+ selectedBoons.push(availableBoons.splice(boonIndex, 1)[0]);
+ }
}
+ if (selectedBoons.length < 3) {
+ selectedBoons.push('Full Heal');
+ }
var background = self.createAsset('boonBackground', 'Boon Selection Popup', 0.5, 0.5);
var boonMessageTitle = new BorderedText('Choose ' + count, {
y: -220,
size: 60,
@@ -247,9 +250,9 @@
boonButton.on('down', function () {
self.destroy();
callback(this.boon);
});
- var boonLevel = new BorderedText(boons[boon], {
+ var boonLevel = new BorderedText(boons[boon] !== undefined ? boons[boon] : '∞', {
x: boonButton.x,
y: boonButton.y,
anchor: {
x: .5,
@@ -344,8 +347,9 @@
args.experiencePickups.forEach(function (experiencePickup) {
experiencePickup.active = true;
});
LK.effects.flashScreen(0xffffff, 1000);
+ return true;
}
}
});
var HealingPickup = Container.expand(function (parent, x, y) {
@@ -579,11 +583,11 @@
var hero = args.hero;
var game = args.game;
var projectiles = args.projectiles;
var scale = 1 + 0.35 * hero.minorBoonLevels['Scale'];
- var range = (200 + 100 * hero.minorBoonLevels['Range']) * (0.9 + 0.2 * Math.random());
+ var range = 200 + 100 * hero.minorBoonLevels['Range'];
var damage = 15 + 10 * hero.minorBoonLevels['Damage'];
- var linger = 0 + 15 * hero.minorBoonLevels['Duration'] + Math.floor(10 * Math.random());
+ var linger = 0 + 15 * hero.minorBoonLevels['Duration'];
var growthRate = 0.25 * hero.majorBoonLevels['Growth'] / 60;
var spreadCount = 1 + hero.majorBoonLevels['Split'];
var dx = hero.shootPos.x - hero.x;
var dy = hero.shootPos.y - hero.y;
@@ -591,14 +595,14 @@
for (var i = 0; i < spreadCount; i++) {
var spreadAngle = spreadCount <= 1 ? 0 : spreadIncrement / 2 * (Math.random() - 0.5);
var angle = baseAngle + i * spreadIncrement + spreadAngle;
projectiles.push(new CrossProjectile(game, hero.x, hero.y, {
+ linger: linger + Math.floor(10 * Math.random()),
+ range: range * (0.9 + 0.2 * Math.random()),
growthRate,
damage,
angle,
- scale,
- range,
- linger
+ scale
}));
}
}
});
@@ -609,11 +613,10 @@
self.x = x;
self.y = y;
var progressBar = args.progressBar;
var onLevelUp = args.onLevelUp;
- var baseMaxHealth = 100;
- self.healthMax = baseMaxHealth;
- self.health = baseMaxHealth;
+ self.healthMax = 100;
+ self.health = self.healthMax;
var experience = 0;
var level = 1;
var levelRequirement = 20;
var healthBar = new HealthBar(self, 0, -self.height / 2 - 10, {
@@ -628,10 +631,10 @@
'Duration': 0,
'Health': 0
};
self.majorBoonLevels = {
- 'Growth': 0,
- 'Split': 0
+ 'Growth': 3,
+ 'Split': 3
};
self.shootPos = {
x,
y
@@ -641,14 +644,8 @@
self.onTakeDamage = onTakeDamage;
self.onHealPercentage = onHealPercentage;
function update(args) {
var game = args.game;
- var newMaxHealth = baseMaxHealth + 30 * self.minorBoonLevels['Health'];
- if (self.healthMax < newMaxHealth) {
- self.healthMax = newMaxHealth;
- self.health = newMaxHealth;
- healthBar.updatePercentage(self.health / self.healthMax);
- }
if (self.targetPos) {
var dx = self.targetPos.x - self.x;
var dy = self.targetPos.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
@@ -686,11 +683,13 @@
LK.showGameOver();
}
}
function onHealPercentage(percentage) {
- self.health = Math.min(self.healthMax, self.health + self.healthMax * percentage);
+ if (percentage > 0) {
+ self.health = Math.min(self.healthMax, self.health + self.healthMax * percentage);
+ LK.effects.flashObject(self.collision, 0x0fa0ff, 1000);
+ }
healthBar.updatePercentage(self.health / self.healthMax);
- LK.effects.flashObject(self.collision, 0x0fa0ff, 1000);
}
});
var Game = Container.expand(function () {
var self = Container.call(this);
@@ -743,8 +742,9 @@
grass.height = 2732;
self.addChild(grass);
self.addChild(aimArrow);
var backgroundContainer = new SectionalContainer(self);
+ var midgroundContainer = new SectionalContainer(self);
var hero = new Hero(self, 2048 / 2, 2732 / 2, {
progressBar,
onLevelUp
});
@@ -792,8 +792,9 @@
updateIteration(enemyProjectiles);
updateIteration(enemies, {
game: self,
backgroundContainer,
+ midgroundContainer,
foregroundContainer,
experiencePickups,
crucifixPickups,
healthPickups,
@@ -823,22 +824,22 @@
var boonSelection;
if (minorBoonCount) {
selectingBoon = true;
boonSelection = new BoonSelection(hero.minorBoonLevels, 'Minor', minorBoonCount, function (boon) {
- if (boon) {
+ minorBoonCount--;
+ if (!checkBoonActions(boon)) {
hero.minorBoonLevels[boon]++;
- minorBoonCount--;
upgradeButton.setCount(minorBoonCount + majorBoonCount);
selectingBoon = false;
showBoonSelection();
}
});
} else if (majorBoonCount) {
selectingBoon = true;
boonSelection = new BoonSelection(hero.majorBoonLevels, 'Major', majorBoonCount, function (boon) {
- if (boon) {
+ majorBoonCount--;
+ if (!checkBoonActions(boon)) {
hero.majorBoonLevels[boon]++;
- majorBoonCount--;
upgradeButton.setCount(minorBoonCount + majorBoonCount);
selectingBoon = false;
showBoonSelection();
}
@@ -852,8 +853,18 @@
}
upgradeButton.setHidden(selectingBoon);
}
}
+ function checkBoonActions(boon) {
+ if (boon === 'Full Heal') {
+ hero.onHealPercentage(1);
+ return true;
+ }
+ if (boon === 'Health') {
+ hero.healthMax += 30;
+ hero.onHealPercentage(0);
+ }
+ }
function spawnEnemy() {
var side = Math.floor(Math.random() * 4);
var distance = Math.random();
var x, y;
pixel art cross with blue accents Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a white orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a white orb with a halo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a pulsating white heart with a halo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a dark goo projectile with red highlights. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art tall blue fireball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of an evil fantasy sword facing downward. Minor red details. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
backgroundAmbient
Sound effect
heroHealed
Sound effect
pickupExperience
Sound effect
heroLeveled
Sound effect
weaponCrossImpact
Sound effect
heroImpact
Sound effect
enemyDeath
Sound effect
pickupWeapon
Sound effect
pickupCrucifix
Sound effect
weaponCrossLaunch
Sound effect
heroDeath
Sound effect
enemyRoar
Sound effect
clockChime
Sound effect