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
User prompt
do not destroy healthpickups when collecting a crucifix
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: self.getAsset is not a function' in this line: 'var arrowGraphics = self.getAsset('arrow', 'Directional Arrow', -1.0, 0.5);' Line Number: 394
Code edit (10 edits merged)
Please save this source code
User prompt
add an arrow asset to the hero that points towards the shootPos
User prompt
create an arrow asset for the hero that points towards from the hero to the shootPos with an offset of 100 units
===================================================================
--- original.js
+++ change.js
@@ -2,14 +2,14 @@
this.data = data;
this.prev = null;
this.next = null;
}
-function DoubleLinkedList() {
+function LinkedList() {
this.head = null;
this.tail = null;
this.length = 0;
}
-DoubleLinkedList.prototype.push = function (data) {
+LinkedList.prototype.push = function (data) {
var node = new Node(data);
if (!this.head) {
this.head = node;
this.tail = node;
@@ -19,9 +19,9 @@
this.tail = node;
}
this.length++;
};
-DoubleLinkedList.prototype.remove = function (node) {
+LinkedList.prototype.remove = function (node) {
if (node.prev) {
node.prev.next = node.next;
} else {
this.head = node.next;
@@ -33,10 +33,16 @@
}
node.prev = null;
node.next = null;
this.length--;
+ return node.data;
};
-DoubleLinkedList.prototype.forEach = function (callback) {
+LinkedList.prototype.popEach = function (callback) {
+ while (this.head) {
+ callback(this.remove(this.head));
+ }
+};
+LinkedList.prototype.forEach = function (callback) {
var node = this.head;
while (node) {
var next = node.next;
callback(node.data, node);
@@ -45,8 +51,9 @@
};
function updateIteration(list, args) {
list.forEach(function (item, node) {
if (item.update(args)) {
+ item.destroy();
list.remove(node);
}
});
}
@@ -126,8 +133,13 @@
for (var i = 0; i < textList.length; i++) {
textList[i].setText(string);
}
};
+ self.setFill = function (fill) {
+ if (textList.length > 0) {
+ textList[textList.length - 1].style.fill = fill;
+ }
+ };
});
var CountdownTimer = Container.expand(function (initialCountdown) {
var self = Container.call(this);
var countdown = initialCountdown;
@@ -291,8 +303,24 @@
self.collisionPoint = new Point(self);
self.x = x;
self.y = y;
var pickupGraphics = self.createAsset('crucifixPickup', 'Crucifix Pickup', .5, .5);
+ self.update = update;
+ function update(args) {
+ var hero = args.hero;
+ if (hero.collision.intersects(self.collisionPoint)) {
+ args.enemies.popEach(function (enemy) {
+ enemy.destroy();
+ });
+ args.enemyProjectiles.popEach(function (enemyProjectile) {
+ enemyProjectile.destroy();
+ });
+ args.experiencePickups.forEach(function (experiencePickup) {
+ experiencePickup.active = true;
+ });
+ LK.effects.flashScreen(0xffffff, 1000);
+ }
+ }
});
var HealingPickup = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
@@ -339,9 +367,9 @@
self.id = args.id;
self.x = x;
self.y = y;
var healthBar = null;
- var damageDistance = 75;
+ var damageDistance = 100;
var heightDifference = 25;
var speed = 2.5;
var damage = 10;
var initialCooldown = 10;
@@ -396,9 +424,9 @@
var crucifixPickups = args.crucifixPickups;
var experiencePickups = args.experiencePickups;
if (crucifixPickups.length < 1 && Math.random() < Math.sqrt(hero.minorBoonLevels['Luck']) / 100) {
crucifixPickups.push(new CrucifixPickup(game, self.x, self.y));
- } else if (healthPickups.length < 5) {
+ } else if (healthPickups.length < 3) {
for (var k = 0; k <= 1 + hero.minorBoonLevels['Luck']; k++) {
if (Math.random() < 0.02) {
healthPickups.push(new HealingPickup(game, self.x, self.y));
break;
@@ -421,9 +449,9 @@
function onTakeDamage(takenDamage) {
health -= takenDamage;
if (health > 0) {
if (!healthBar) {
- healthBar = new HealthBar(self, 0, -self.collision / 2 - 50, {
+ healthBar = new HealthBar(self, 0, -self.collision.height / 2 + 50, {
tint: 0xaa0000
});
}
healthBar.updatePercentage(health / healthMax);
@@ -483,18 +511,17 @@
}
}
range -= Math.abs(speed);
var tick = LK.ticks;
- for (var i = 0; i < enemies.length; i++) {
- var enemy = enemies[i];
+ enemies.forEach(function (enemy) {
if (enemy.collision.intersects(self)) {
var lastHitTick = hitMap[enemy.id];
if (!lastHitTick || tick - lastHitTick > 10) {
hitMap[enemy.id] = tick;
enemy.onTakeDamage(damage);
}
}
- }
+ });
return (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) && range < destroyRange || hero.collision.intersects(self.collisionPoint) && speed < 0;
}
});
var CrossWeapon = Container.expand(function (parent) {
@@ -519,34 +546,28 @@
function launch(args) {
var hero = args.hero;
var game = args.game;
var projectiles = args.projectiles;
- var dx = hero.shootPos.x - hero.x;
- var dy = hero.shootPos.y - hero.y;
- var baseAngle = Math.atan2(dy, dx);
var scale = 1 + 0.35 * hero.minorBoonLevels['Scale'];
- var range = 200 + 75 * hero.minorBoonLevels['Range'];
+ var range = 200 + 100 * hero.minorBoonLevels['Range'] + 50 * Math.random();
var damage = 15 + 10 * hero.minorBoonLevels['Damage'];
- var linger = 0 + 15 * hero.minorBoonLevels['Duration'];
+ var linger = 0 + 15 * hero.minorBoonLevels['Duration'] + Math.floor(5 * Math.random());
var growthRate = 0.25 * hero.majorBoonLevels['Growth'] / 60;
- var radialCount = 1 + hero.majorBoonLevels['Extra'];
- var spreadCount = 1 + hero.majorBoonLevels['Spread'];
- var radialIncrement = Math.PI * 2 / radialCount;
- baseAngle -= spreadCount * spreadIncrement / 2;
- for (var i = 0; i < radialCount; i++) {
- var radialAngle = baseAngle + i * radialIncrement;
- for (var j = 0; j < spreadCount; j++) {
- var spreadAngle = spreadCount <= 1 ? 0 : spreadIncrement / 2 * (Math.random() - 0.5);
- var angle = radialAngle + j * spreadIncrement + spreadAngle;
- projectiles.push(new CrossProjectile(game, hero.x, hero.y, {
- growthRate,
- damage,
- angle,
- scale,
- range,
- linger
- }));
- }
+ var spreadCount = 1 + hero.majorBoonLevels['Split'];
+ var dx = hero.shootPos.x - hero.x;
+ var dy = hero.shootPos.y - hero.y;
+ var baseAngle = Math.atan2(dy, dx) - spreadCount * spreadIncrement / 2;
+ 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, {
+ growthRate,
+ damage,
+ angle,
+ scale,
+ range,
+ linger
+ }));
}
}
});
var Hero = Container.expand(function (parent, x, y, args) {
@@ -576,10 +597,9 @@
'Health': 0
};
self.majorBoonLevels = {
'Growth': 0,
- 'Spread': 3,
- 'Extra': 0
+ 'Split': 0
};
self.shootPos = {
x,
y
@@ -667,16 +687,16 @@
var selectingBoon = false;
var progressBarBorder = LK.getAsset('progressBarBorder', 'Progress Bar Border', 0, .5);
var progressBar = LK.getAsset('progressBar', 'Progress Bar', 0, .5);
var enemyIdCounter = -1;
- var heroProjectiles = DoubleLinkedList();
- var enemyProjectiles = DoubleLinkedList();
- var weapons = DoubleLinkedList();
- var enemies = DoubleLinkedList();
- var healthPickups = DoubleLinkedList();
- var crucifixPickups = DoubleLinkedList();
- var experiencePickups = DoubleLinkedList();
- var effects = DoubleLinkedList();
+ var heroProjectiles = new LinkedList();
+ var enemyProjectiles = new LinkedList();
+ var weapons = new LinkedList();
+ var enemies = new LinkedList();
+ var healthPickups = new LinkedList();
+ var crucifixPickups = new LinkedList();
+ var experiencePickups = new LinkedList();
+ var effects = new LinkedList();
var countdownTimer = new CountdownTimer(300);
LK.gui.topCenter.addChild(countdownTimer);
LK.gui.topCenter.addChild(progressBarBorder);
LK.gui.topCenter.addChild(progressBar);
@@ -754,25 +774,15 @@
});
updateIteration(healthPickups, {
hero
});
- crucifixPickups.forEach(function (crucifixPickup) {
- if (hero.collision.intersects(crucifixPickup.collisionPoint)) {
- enemies.forEach(function (enemy) {
- enemy.destroy();
- });
- enemyProjectiles.forEach(function (enemyProjectile) {
- enemyProjectile.destroy();
- });
- experiencePickups.forEach(function (experiencePickup) {
- experiencePickup.active = true;
- });
- enemies = DoubleLinkedList();
- enemyProjectiles = DoubleLinkedList();
- LK.effects.flashScreen(0xffffff, 1000);
- }
+ updateIteration(crucifixPickups, {
+ experiencePickups,
+ enemyProjectiles,
+ enemies,
+ hero
});
- if (LK.ticks % (60 - Math.floor(50 * difficultyScale)) === 0) {
+ if (LK.ticks % Math.max(10, 60 - Math.floor(50 * difficultyScale)) === 0) {
spawnEnemy();
}
}
});
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