Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #30 from MochicStudio/dev
Browse files Browse the repository at this point in the history
Render explosion on player-enemy collide
  • Loading branch information
andresruizdc authored Jan 23, 2021
2 parents 7078fc5 + 150abc7 commit 00ac8a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/scenes/PlayGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,13 @@ export class PlayGame extends Phaser.Scene {
/* If the enemy spaceship and the player are the same color, then
* kill the enemy and kill the player. */
if(this.isPlayerAndEnemySameColor(player.texture.key, enemy.texture.key)){
enemy.destroy();
this.lives -= 1;
this.livesText.setText("Lives: " + this.lives);

enemy.destroy();
this.renderExplosion({ x: enemy.x, y: enemy.y }, this.getColor(enemy.texture.key));
this.renderExplosion({ x: player.x, y: player.y }, this.getColor(player.texture.key));
this.player.setX(this.game.config.width / 2);
}
});
}
Expand Down

0 comments on commit 00ac8a7

Please sign in to comment.