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
User prompt
Here's a list of things to do: 1) set enemy health bar offset from 50 to -50. 2) Increase enemy attack range from 100. 3) Add a setFill function to the BorderText, which sets the fill of the last element of textList. 4) Reduce healingpickup limit from 5 to 3.
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: weapons is undefined' in this line: 'weapons.push(new CrossWeapon(self));' Line Number: 700
Code edit (1 edits merged)
Please save this source code
User prompt
Create a DoubleLinkedList class with Node class for linked list elements
Code edit (4 edits merged)
Please save this source code
User prompt
add a function that creates a generic linkedlist
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: t.setStageReference is not a function' in this line: 'parent.addChild(self);' Line Number: 12
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: heroGraphics is not defined' in this line: 'LK.effects.flashObject(heroGraphics, 0xaa0000, 1000);' Line Number: 474
Code edit (8 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: projectileCount is not defined' in this line: 'var angleIncrement = Math.PI * 2 / projectileCount;' Line Number: 376
Code edit (6 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,7 @@
-function updateIteration(container, vars) {
+function updateIteration(container, args) {
for (var i = 0; i < container.length; i++) {
- if (container[i].update(vars)) {
+ if (container[i].update(args)) {
container[i].destroy();
container.splice(i, 1);
i--;
}
@@ -117,8 +117,105 @@
var secondsString = (seconds < 10 ? '0' : '') + seconds;
countdownTxt.setText(minutesString + ':' + secondsString);
}
});
+var BoonUpgradeButton = Container.expand(function (parent, x, y, args) {
+ var self = Container.call(this);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
+ var fill = args.fill;
+ var hidden = false;
+ var count = 0;
+ var button = self.createAsset('boonButton', 'Boon Upgrade Button', 0.5, 0.4);
+ var countTxt = new BorderedText('0', {
+ fill: '#ff0000',
+ anchor: {
+ x: .5,
+ y: .5
+ }
+ });
+ button.on('down', args.callback);
+ self.addChild(countTxt);
+ self.visible = false;
+ self.setHidden = setHidden;
+ self.setCount = setCount;
+ function setHidden(newHidden) {
+ hidden = newHidden;
+ checkHidden();
+ }
+ function setCount(newCount) {
+ count = newCount;
+ countTxt.setText(newCount);
+ checkHidden();
+ }
+ function checkHidden() {
+ self.visible = !hidden && count > 0;
+ }
+});
+var BoonSelection = Container.expand(function (boons, type, count, callback) {
+ 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]);
+ }
+ var background = self.createAsset('boonBackground', 'Boon Selection Popup', 0.5, 0.5);
+ var boonMessageTitle = new BorderedText('Choose ' + count, {
+ y: -220,
+ size: 60,
+ anchor: {
+ x: .5,
+ y: 0
+ }
+ });
+ background.y = 50;
+ self.addChild(boonMessageTitle);
+ var boonMessageSubtitle = new BorderedText(type + ' Boon' + (count === 1 ? '' : 's'), {
+ y: -150,
+ anchor: {
+ x: .5,
+ y: 0
+ }
+ });
+ self.addChild(boonMessageSubtitle);
+ for (var i = 0; i < selectedBoons.length; i++) {
+ var boon = selectedBoons[i];
+ var boonButton = self.createAsset('boonButton', 'Boon Button', 0.5, 0.4);
+ boonButton.y = i * 120;
+ boonButton.x = -120;
+ boonButton.boon = boon;
+ boonButton.on('down', function () {
+ self.destroy();
+ callback(this.boon);
+ });
+ var boonLevel = new BorderedText(boons[boon], {
+ x: boonButton.x,
+ y: boonButton.y,
+ anchor: {
+ x: .5,
+ y: .5
+ }
+ });
+ var boonName = new BorderedText(boon, {
+ x: boonButton.x + 60,
+ y: boonButton.y,
+ anchor: {
+ x: 0,
+ y: .5
+ }
+ });
+ self.addChild(boonLevel);
+ self.addChild(boonName);
+ }
+});
var ExperiencePickup = Container.expand(function (parent, x, y, experience) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
@@ -155,9 +252,9 @@
});
var HealingPickup = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
- self.collisionPoint = Point(self);
+ self.collisionPoint = new Point(self);
self.x = x;
self.y = y;
var pickupGraphics = self.createAsset('healingPickup', 'Healing Pickup', .5, .5);
var healPercentage = 0.1;
@@ -199,9 +296,10 @@
self.id = args.id;
self.x = x;
self.y = y;
var healthBar = null;
- var damageDistance = 50;
+ var damageDistance = 75;
+ var heightDifference = 25;
var speed = 2.5;
var damage = 10;
var initialCooldown = 10;
var cooldown = initialCooldown;
@@ -221,10 +319,10 @@
var hero = args.hero;
var game = args.game;
var backgroundContainer = args.backgroundContainer;
var foregroundContainer = args.foregroundContainer;
- var dx = hero.x + 50 - self.x;
- var dy = hero.y - self.y;
+ var dx = hero.x - self.x;
+ var dy = hero.y + heightDifference - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > damageDistance) {
self.x += dx / distance * speed;
self.y += dy / distance * speed + Math.sin((LK.ticks - creationTick) / bobPeriod) * bobMagnitude;
@@ -236,9 +334,9 @@
hero.onTakeDamage(damage);
}
}
var newParent;
- if (self.y <= hero.y) {
+ if (self.y <= hero.y + heightDifference) {
newParent = backgroundContainer;
} else {
newParent = foregroundContainer;
}
@@ -280,14 +378,14 @@
function onTakeDamage(takenDamage) {
health -= takenDamage;
if (health > 0) {
if (!healthBar) {
- healthBar = new HealthBar(self, 0, -enemyGraphics.height / 2 - 50, {
+ healthBar = new HealthBar(self, 0, -self.collision / 2 - 50, {
tint: 0xaa0000
});
}
healthBar.updatePercentage(health / healthMax);
- LK.effects.flashObject(enemyGraphics, 0xaa0000, 1000);
+ LK.effects.flashObject(self.collision, 0xaa0000, 1000);
}
}
});
var CrossProjectile = Container.expand(function (parent, x, y, args) {
@@ -494,74 +592,11 @@
}
function onHealPercentage(percentage) {
health = Math.min(healthMax, health + healthMax * percentage);
healthBar.updatePercentage(health / healthMax);
- LK.effects.flashObject(heroGraphics, 0x0fa0ff, 1000);
+ LK.effects.flashObject(self.collision, 0x0fa0ff, 1000);
}
});
-var BoonSelection = Container.expand(function (boons, type, count, callback) {
- 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]);
- }
- var background = self.createAsset('boonBackground', 'Boon Selection Popup', 0.5, 0.5);
- var boonMessageTitle = new BorderedText('Choose ' + count, {
- y: -220,
- size: 60,
- anchor: {
- x: .5,
- y: 0
- }
- });
- background.y = 50;
- self.addChild(boonMessageTitle);
- var boonMessageSubtitle = new BorderedText(type + ' Boon' + (count === 1 ? '' : 's'), {
- y: -150,
- anchor: {
- x: .5,
- y: 0
- }
- });
- self.addChild(boonMessageSubtitle);
- for (var i = 0; i < selectedBoons.length; i++) {
- var boon = selectedBoons[i];
- var boonButton = self.createAsset('boonButton', 'Boon Button', 0.5, 0.5);
- boonButton.y = i * 120;
- boonButton.x = -100;
- boonButton.boon = boon;
- boonButton.on('down', function () {
- self.destroy();
- callback(this.boon);
- });
- var boonLevel = new BorderedText(boons[boon], {
- x: boonButton.x,
- y: boonButton.y,
- anchor: {
- x: .5,
- y: .5
- }
- });
- var boonName = new BorderedText(boon, {
- x: boonButton.x + 60,
- y: boonButton.y,
- anchor: {
- x: 0,
- y: .5
- }
- });
- self.addChild(boonLevel);
- self.addChild(boonName);
- }
-});
var Game = Container.expand(function () {
var self = Container.call(this);
var isPaused = false;
var minorBoonCount = 0;
@@ -569,28 +604,16 @@
var grass = LK.getAsset('grass', 'Grass Background', 0, 0);
var aimArrow = LK.getAsset('arrow', 'Directional Arrow', -2.5, 0.5);
var canMove = false;
var difficultyScale = 0;
- var availableBoonsTxt = new BorderedText('0', {
- x: -70,
- y: 70,
+ var upgradeButton = new BoonUpgradeButton(LK.gui.topRight, -80, 60, {
fill: '#ff0000',
- anchor: {
- x: .5,
- y: .5
+ callback: function () {
+ if (minorBoonCount + majorBoonCount > 0) {
+ showBoonSelection();
+ }
}
});
- var upgradeButton = LK.gui.topRight.createAsset('upgradeButton', 'Upgrade Button', 0.5, 0.5);
- LK.gui.topRight.addChild(availableBoonsTxt);
- grass.width = 2048;
- grass.height = 2732;
- upgradeButton.x = -70;
- upgradeButton.y = 70;
- upgradeButton.on('down', function () {
- if (minorBoonCount + majorBoonCount > 0) {
- showBoonSelection();
- }
- });
var levelTxt = new BorderedText('Level 1 • XP', {
anchor: {
x: 1.0,
y: 0
@@ -619,9 +642,10 @@
progressBarBorder.y = levelTxt.y + levelTxt.height / 2;
progressBar.x = 24;
progressBar.y = levelTxt.y + levelTxt.height / 2;
progressBar.scale.x = 0;
- self.targetPos = null;
+ grass.width = 2048;
+ grass.height = 2732;
self.addChild(grass);
self.addChild(aimArrow);
var backgroundContainer = new SectionalContainer(self);
var hero = new Hero(self, 2048 / 2, 2732 / 2, {
@@ -629,9 +653,8 @@
onLevelUp
});
weapons.push(new CrossWeapon(self));
var foregroundContainer = new SectionalContainer(self);
- refreshBoonUpgradeButton();
stage.on('down', function (obj) {
canMove = true;
hero.targetPos = obj.event.getLocalPosition(self);
});
@@ -714,14 +737,8 @@
spawnEnemy();
}
}
});
- function refreshBoonUpgradeButton() {
- var bool = !selectingBoon && minorBoonCount + majorBoonCount > 0;
- upgradeButton.visible = bool;
- availableBoonsTxt.visible = bool;
- availableBoonsTxt.setText(minorBoonCount + majorBoonCount);
- }
function showBoonSelection() {
if (!selectingBoon) {
var boonSelection;
if (minorBoonCount) {
@@ -729,10 +746,10 @@
boonSelection = new BoonSelection(hero.minorBoonLevels, 'Minor', minorBoonCount, function (boon) {
if (boon) {
hero.minorBoonLevels[boon]++;
minorBoonCount--;
+ upgradeButton.setCount(minorBoonCount + majorBoonCount);
selectingBoon = false;
- refreshBoonUpgradeButton();
showBoonSelection();
}
});
} else if (majorBoonCount) {
@@ -740,10 +757,10 @@
boonSelection = new BoonSelection(hero.majorBoonLevels, 'Major', majorBoonCount, function (boon) {
if (boon) {
hero.majorBoonLevels[boon]++;
majorBoonCount--;
+ upgradeButton.setCount(minorBoonCount + majorBoonCount);
selectingBoon = false;
- refreshBoonUpgradeButton();
showBoonSelection();
}
});
}
@@ -752,9 +769,9 @@
LK.gui.center.addChild(boonSelection);
} else {
isPaused = false;
}
- refreshBoonUpgradeButton();
+ upgradeButton.setHidden(selectingBoon);
}
}
function spawnEnemy() {
var side = Math.floor(Math.random() * 4);
@@ -789,7 +806,7 @@
minorBoonCount++;
} else {
majorBoonCount++;
}
- refreshBoonUpgradeButton();
+ upgradeButton.setCount(minorBoonCount + majorBoonCount);
}
});
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