aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autoload/space_vlaze/game.vim29
-rw-r--r--autoload/space_vlaze/mappings.vim21
-rw-r--r--autoload/space_vlaze/player.vim14
3 files changed, 63 insertions, 1 deletions
diff --git a/autoload/space_vlaze/game.vim b/autoload/space_vlaze/game.vim
index e975bd6..0f822d1 100644
--- a/autoload/space_vlaze/game.vim
+++ b/autoload/space_vlaze/game.vim
@@ -1,10 +1,18 @@
function! space_vlaze#game#Init()
+ let s:loop = 1
let s:score = 0
let s:start_time = localtime()
call space_vlaze#game#SetupWindow()
call space_vlaze#colors#Initialize()
call space_vlaze#game#InitializeBoard()
call space_vlaze#mappings#Initialize()
+
+ while s:loop ==# 1
+ sleep 50ms
+ call space_vlaze#mappings#Listen()
+ call space_vlaze#game#RenderBoard()
+ redraw!
+ endwhile
endfunction
@@ -56,7 +64,28 @@ function! space_vlaze#game#RenderBoard()
endfunction
+function! space_vlaze#game#Board()
+ return s:board
+endfunction
+
+
+function! space_vlaze#game#SetBoardCell(y, x, value)
+ let s:board[a:y][a:x] = a:value
+endfunction
+
+
+function! space_vlaze#game#PlayerY()
+ return s:PLAYER_Y
+endfunction
+
+function! space_vlaze#game#PlayerX()
+ return s:PLAYER_X
+endfunction
+
+
+
function! space_vlaze#game#Quit()
+ let s:loop = -1
endfunction
diff --git a/autoload/space_vlaze/mappings.vim b/autoload/space_vlaze/mappings.vim
index 65cfe6e..9194eb0 100644
--- a/autoload/space_vlaze/mappings.vim
+++ b/autoload/space_vlaze/mappings.vim
@@ -7,3 +7,24 @@ function! space_vlaze#mappings#Initialize()
nnoremap <silent><buffer> l :call space_vlaze#player#MoveRight()<cr>
nnoremap <silent><buffer> <space> :call space_vlaze#player#FireBlasters()<cr>
endfunction
+
+
+function! space_vlaze#mappings#Listen()
+ let c = nr2char(getchar(0))
+
+ if c ==# 'q'
+ call space_vlaze#game#Quit()
+ elseif c ==# 'p'
+ call space_vlaze#game#Pause()
+ elseif c ==# 'h'
+ call space_vlaze#player#MoveLeft()
+ elseif c ==# 'j'
+ call space_vlaze#player#MoveDown()
+ elseif c ==# 'k'
+ call space_vlaze#player#MoveUp()
+ elseif c ==# 'l'
+ call space_vlaze#player#MoveRight()
+ elseif c ==# '\<space>'
+ call space_vlaze#player#FireBlasters()
+ endif
+endfunction
diff --git a/autoload/space_vlaze/player.vim b/autoload/space_vlaze/player.vim
index 17b0178..f3340db 100644
--- a/autoload/space_vlaze/player.vim
+++ b/autoload/space_vlaze/player.vim
@@ -3,20 +3,32 @@ function! space_vlaze#player#PlayerCharacter()
endfunction
+function! space_vlaze#player#ClearPlayerCell()
+ call space_vlaze#game#SetBoardCell(space_vlaze#game#PlayerY(), space_vlaze#game#PlayerX(), ' ')
+endfunction
+
+
function! space_vlaze#player#MoveLeft()
+ call space_vlaze#player#ClearPlayerCell()
+ call space_vlaze#game#SetBoardCell(space_vlaze#game#PlayerY(), space_vlaze#game#PlayerX() - 1, space_vlaze#player#PlayerCharacter())
endfunction
function! space_vlaze#player#MoveDown()
- echom 'booya'
+ call space_vlaze#player#ClearPlayerCell()
+ call space_vlaze#game#SetBoardCell(space_vlaze#game#PlayerY() + 1, space_vlaze#game#PlayerX(), space_vlaze#player#PlayerCharacter())
endfunction
function! space_vlaze#player#MoveUp()
+ call space_vlaze#player#ClearPlayerCell()
+ call space_vlaze#game#SetBoardCell(space_vlaze#game#PlayerY() - 1, space_vlaze#game#PlayerX(), space_vlaze#player#PlayerCharacter())
endfunction
function! space_vlaze#player#MoveRight()
+ call space_vlaze#player#ClearPlayerCell()
+ call space_vlaze#game#SetBoardCell(space_vlaze#game#PlayerY(), space_vlaze#game#PlayerX() + 1, space_vlaze#player#PlayerCharacter())
endfunction