Code edit (1 edits merged)
Please save this source code
User prompt
The fireballprojectiles enemy for-loop should use the LinkedList foreach instead
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
===================================================================
--- original.js
+++ change.js
@@ -56,18 +56,106 @@
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;
self.y = y;
var collision = self.createAsset('blank', 'Collision', .5, .5);
- collision.tint = 0xff0000;
- collision.width = 10;
- collision.height = 10;
collision.opacity = 1;
+ collision.tint = 0xff0000;
+ collision.width = 1;
+ collision.height = 1;
});
var HealthBar = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
@@ -409,9 +497,9 @@
var bobMagnitude = 2;
var bobPeriod = 10;
var creationTick = LK.ticks;
var parent = parent;
- var healthMax = 5 + 25 * args.difficultyScale;
+ var healthMax = 10 + 50 * args.difficultyScale;
var health = healthMax;
self.update = update;
self.onTakeDamage = onTakeDamage;
function update(args) {
@@ -497,18 +585,20 @@
var self = Container.call(this);
parent.addChild(self);
var enemyIdCounter = -1;
var spawnRate = 60;
+ var spawnLimit = 50;
var spawnTimer = spawnRate;
self.update = update;
function update(args) {
- spawnTimer--;
- if (spawnTimer <= 0) {
- spawnTimer = Math.max(10, spawnRate - Math.floor(50 * args.difficultyScale));
- spawnEnemy(args);
+ if (args.enemies.length < spawnLimit) {
+ spawnTimer--;
+ if (spawnTimer <= 0) {
+ spawnTimer = Math.max(10, spawnRate - Math.floor(50 * args.difficultyScale));
+ spawnEnemy(args);
+ }
}
}
- ;
function spawnEnemy(args) {
var side = Math.floor(Math.random() * 4);
var distance = Math.random();
var x, y;
@@ -636,9 +726,9 @@
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 spreadAngle = spreadIncrement / 2 * (spreadCount <= 1 ? 1 : 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()),
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