diff options
| author | Teddy Wing | 2015-10-07 02:45:32 -0400 |
|---|---|---|
| committer | Teddy Wing | 2015-10-07 02:47:50 -0400 |
| commit | dd70d247ec64d68188ba28a2a25ee02de82f8d8c (patch) | |
| tree | 2cf93904f951ce3e6ee7aeedfa12471bdfe26218 /autoload | |
| parent | 5957bb609e7e763fe83b4b695b3600c14a81d9d4 (diff) | |
| download | vim-space-vlaze-dd70d247ec64d68188ba28a2a25ee02de82f8d8c.tar.bz2 | |
Hitting enemies with missiles makes enemies disappear
When a missile hits an enemy, the enemy now disappears.
TODO:
* Add scoring
* Currently missiles don't stop when they hit an enemy so they'll just
keep on killing enemies until they get to the edge of the board.
Diffstat (limited to 'autoload')
| -rw-r--r-- | autoload/space_vlaze/enemy.vim | 13 | ||||
| -rw-r--r-- | autoload/space_vlaze/missile.vim | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/autoload/space_vlaze/enemy.vim b/autoload/space_vlaze/enemy.vim index 51bf14d..1fefbf5 100644 --- a/autoload/space_vlaze/enemy.vim +++ b/autoload/space_vlaze/enemy.vim @@ -51,3 +51,16 @@ function! space_vlaze#enemy#DropEnemyAtRandomCoordinates() call space_vlaze#game#SetBoardCell(y, x, space_vlaze#enemy#EnemyCharacter()) endfunction + + +" Calling this function tells us that coordinates y, x were hit by a missile. +" If an enemy lives at y, x, it needs to disappear and update the score. +function! space_vlaze#enemy#HandleEnemyHitAt(y, x) + if space_vlaze#game#IsWithinBoard(a:y, a:x) + if space_vlaze#game#BoardCell(a:y, a:x) ==# space_vlaze#enemy#EnemyCharacter() + call space_vlaze#game#ClearBoardCell(a:y, a:x) + + return 1 + endif + endif +endfunction diff --git a/autoload/space_vlaze/missile.vim b/autoload/space_vlaze/missile.vim index aa9da39..95f4e94 100644 --- a/autoload/space_vlaze/missile.vim +++ b/autoload/space_vlaze/missile.vim @@ -51,6 +51,8 @@ function! space_vlaze#missile#Move(y, x, direction) call space_vlaze#game#RenderBoard() return 1 + else + call space_vlaze#enemy#HandleEnemyHitAt(y, x) endif return 0 |
