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
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
===================================================================
--- original.js
+++ change.js
@@ -56,96 +56,8 @@
list.remove(node);
}
});
}
-var EnemyProjectile = Container.expand(function (parent, x, y, args) {
- var self = Container.call(this);
- parent.addChild(self);
- self.x = x;
- self.y = y;
- self.collisionPoint = new Point(self);
- var projectileAsset = self.createAsset('enemyProjectile', 'Enemy Projectile', .5, .5);
- var speed = 5;
- var target = args.target;
- var damage = args.damage;
- self.update = update;
- function update() {
- var dx = target.x - self.x;
- var dy = target.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance > 0) {
- self.x += dx / distance * speed;
- self.y += dy / distance * speed;
- }
- if (target.collision.intersects(self.collisionPoint)) {
- target.onTakeDamage(damage);
- return true;
- }
- return self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732;
- }
-});
-var RangedEnemy = Container.expand(function (parent, x, y, args) {
- var self = Container.call(this);
- parent.addChild(self);
- self.collision = self.createAsset('rangedEnemy', 'Ranged Enemy', .5, .5);
- self.id = args.id;
- self.x = x;
- self.y = y;
- var healthBar = null;
- var attackRange = 500;
- var heightDifference = 25;
- var speed = 1.5;
- var damage = 5;
- var initialCooldown = 120;
- var cooldown = initialCooldown;
- var healthMax = 20 + 30 * args.difficultyScale;
- var health = healthMax;
- self.update = update;
- self.onTakeDamage = onTakeDamage;
- function update(args) {
- if (health <= 0) {
- kill(args);
- return true;
- }
- var hero = args.hero;
- var dx = hero.x - self.x;
- var dy = hero.y + heightDifference - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < attackRange) {
- cooldown--;
- if (cooldown <= 0) {
- cooldown = initialCooldown;
- args.enemyProjectiles.push(new EnemyProjectile(args.midgroundContainer, self.x, self.y, {
- target: hero,
- damage: damage
- }));
- }
- } else {
- self.x += dx / distance * speed;
- self.y += dy / distance * speed;
- }
- var newParent = distance <= hero.y + heightDifference ? args.midgroundContainer : args.foregroundContainer;
- if (parent !== newParent) {
- newParent.addChild(self);
- parent = newParent;
- }
- }
- function kill(args) {
- args.effects.push(new BasicBloodSplatter(parent, self.x, self.y));
- }
- function onTakeDamage(takenDamage) {
- health -= takenDamage;
- if (health > 0) {
- if (!healthBar) {
- healthBar = new HealthBar(self, 0, -self.collision.height / 2 - 50, {
- tint: 0xaa0000
- });
- }
- healthBar.updatePercentage(health / healthMax);
- LK.effects.flashObject(self.collision, 0xaa0000, 1000);
- }
- }
-});
var Point = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
@@ -479,8 +391,96 @@
y: newScale
};
}
});
+var EnemyProjectile = Container.expand(function (parent, x, y, args) {
+ var self = Container.call(this);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
+ self.collisionPoint = new Point(self);
+ var projectileAsset = self.createAsset('enemyProjectile', 'Enemy Projectile', .5, .5);
+ var speed = 5;
+ var target = args.target;
+ var damage = args.damage;
+ self.update = update;
+ function update() {
+ var dx = target.x - self.x;
+ var dy = target.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 0) {
+ self.x += dx / distance * speed;
+ self.y += dy / distance * speed;
+ }
+ if (target.collision.intersects(self.collisionPoint)) {
+ target.onTakeDamage(damage);
+ return true;
+ }
+ return self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732;
+ }
+});
+var RangedEnemy = Container.expand(function (parent, x, y, args) {
+ var self = Container.call(this);
+ parent.addChild(self);
+ self.collision = self.createAsset('rangedEnemy', 'Ranged Enemy', .5, .5);
+ self.id = args.id;
+ self.x = x;
+ self.y = y;
+ var healthBar = null;
+ var attackRange = 500;
+ var heightDifference = 25;
+ var speed = 1.5;
+ var damage = 5;
+ var initialCooldown = 120;
+ var cooldown = initialCooldown;
+ var healthMax = 20 + 30 * args.difficultyScale;
+ var health = healthMax;
+ self.update = update;
+ self.onTakeDamage = onTakeDamage;
+ function update(args) {
+ if (health <= 0) {
+ kill(args);
+ return true;
+ }
+ var hero = args.hero;
+ var dx = hero.x - self.x;
+ var dy = hero.y + heightDifference - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < attackRange) {
+ cooldown--;
+ if (cooldown <= 0) {
+ cooldown = initialCooldown;
+ args.enemyProjectiles.push(new EnemyProjectile(args.midgroundContainer, self.x, self.y, {
+ target: hero,
+ damage: damage
+ }));
+ }
+ } else {
+ self.x += dx / distance * speed;
+ self.y += dy / distance * speed;
+ }
+ var newParent = distance <= hero.y + heightDifference ? args.midgroundContainer : args.foregroundContainer;
+ if (parent !== newParent) {
+ newParent.addChild(self);
+ parent = newParent;
+ }
+ }
+ function kill(args) {
+ args.effects.push(new BasicBloodSplatter(parent, self.x, self.y));
+ }
+ function onTakeDamage(takenDamage) {
+ health -= takenDamage;
+ if (health > 0) {
+ if (!healthBar) {
+ healthBar = new HealthBar(self, 0, -self.collision.height / 2 - 50, {
+ tint: 0xaa0000
+ });
+ }
+ healthBar.updatePercentage(health / healthMax);
+ LK.effects.flashObject(self.collision, 0xaa0000, 1000);
+ }
+ }
+});
var BasicEnemy = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.collision = self.createAsset('enemy', 'Basic Enemy', .5, .5);
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