Browse Source

Made projectiles kill other projectiles.

master
Jeasonfire 4 years ago
parent
commit
b29c97ae90
3 changed files with 12 additions and 5 deletions
  1. BIN
      res/projectile_basic.png
  2. +3
    -3
      src/mechanics/enemy.ts
  3. +9
    -2
      src/mechanics/projectile.ts

BIN
res/projectile_basic.png View File

Before After
Width: 2  |  Height: 1  |  Size: 145 B Width: 2  |  Height: 1  |  Size: 144 B

+ 3
- 3
src/mechanics/enemy.ts View File

@ -62,7 +62,7 @@ class Enemy extends Entity {
return (self: Enemy, level: Level) => {
if (self.data["shoot_count"] === undefined) {
self.data["shoot_count"] = 0;
self.data["cooldown_count"] = self.shooting_rate / 2.0;
self.data["cooldown_count"] = self.shooting_rate / 1.5;
self.data["original_shooting_rate"] = self.shooting_rate;
self.data["origin"] = self.y;
self.data["shooting"] = false;
@ -106,9 +106,9 @@ class Enemy extends Entity {
case EnemyType.FIGHTER:
return 0.5;
case EnemyType.FIGHTER_MKII:
return 8;
return 5;
case EnemyType.FIGHTER_MKIII:
return 16;
return 15;
}
}
}

+ 9
- 2
src/mechanics/projectile.ts View File

@ -19,12 +19,19 @@ class Projectile extends Entity {
return;
}
for (let i = 0; i < level.enemies.length; i++) {
if (level.enemies[i].get_hitbox().contains(this.x, this.y)) {
if (!level.enemies[i].is_dead() && level.enemies[i].get_hitbox().contains(this.x, this.y)) {
level.enemies[i].take_damage(1);
ParticleManager.burst(this.x, this.y, 0.15, 6);
this.dead = true;
}
}
for (let i = 0; i < level.projectiles.length; i++) {
if (level.projectiles[i] !== this && !level.projectiles[i].dead && level.projectiles[i].get_hitbox().contains(this.x, this.y)) {
ParticleManager.burst(this.x, this.y, 0.5, 5, 100);
level.projectiles[i].dead = true;
this.dead = true;
}
}
if (level.player.get_hitbox().contains(this.x, this.y)) {
level.player.take_damage(1);
ParticleManager.burst(this.x, this.y, 0.1, 3);
@ -45,7 +52,7 @@ class Projectile extends Entity {
default:
case ProjectileType.BASIC:
return (self: Projectile, level: Level) => {
self.x += self.direction * 100 * Time.delta;
self.x += self.direction * 80 * Time.delta;
};
}
}


Loading…
Cancel
Save