diff options
| author | Teddy Wing | 2015-10-04 12:41:37 -0400 | 
|---|---|---|
| committer | Teddy Wing | 2015-10-04 12:41:37 -0400 | 
| commit | 864b87d37a5c19e0445a3fb124ea154b201d5ae3 (patch) | |
| tree | fd5c2f0cebd76b143f1ddbff093137871c8995ec | |
| download | vim-space-vlaze-864b87d37a5c19e0445a3fb124ea154b201d5ae3.tar.bz2 | |
Initial commit. Initial menu and board state
Setup layout and structure of the code.
* Add a command and map to start the game
* When the game is started, prompt for game start, help, or leaderboard
* Create help file template (TODO)
* On game start, initialise the board with spaces and a player character
* Setup buffer locals on game start
* Create various functions that we'll need coming up either as stubs or
  filled in with what they'll probably be.
| -rw-r--r-- | autoload/space_vlaze.vim | 3 | ||||
| -rw-r--r-- | autoload/space_vlaze/buffer.vim | 17 | ||||
| -rw-r--r-- | autoload/space_vlaze/colors.vim | 3 | ||||
| -rw-r--r-- | autoload/space_vlaze/game.vim | 53 | ||||
| -rw-r--r-- | autoload/space_vlaze/help.vim | 4 | ||||
| -rw-r--r-- | autoload/space_vlaze/mappings.vim | 9 | ||||
| -rw-r--r-- | autoload/space_vlaze/menus.vim | 21 | ||||
| -rw-r--r-- | autoload/space_vlaze/player.vim | 3 | ||||
| -rw-r--r-- | doc/space_vlaze.txt | 1 | ||||
| -rw-r--r-- | doc/tags | 1 | ||||
| -rw-r--r-- | plugin/space_vlaze.vim | 10 | 
11 files changed, 125 insertions, 0 deletions
| diff --git a/autoload/space_vlaze.vim b/autoload/space_vlaze.vim new file mode 100644 index 0000000..3b1db7a --- /dev/null +++ b/autoload/space_vlaze.vim @@ -0,0 +1,3 @@ +function! space_vlaze#Start() +	call space_vlaze#buffer#Init() +endfunction diff --git a/autoload/space_vlaze/buffer.vim b/autoload/space_vlaze/buffer.vim new file mode 100644 index 0000000..dfbe47f --- /dev/null +++ b/autoload/space_vlaze/buffer.vim @@ -0,0 +1,17 @@ +function! space_vlaze#buffer#Init() +	let s:buffer_name = 'Space Vlaze' +	 +	if !buflisted(s:buffer_name) +		" call space_vlaze#game#Init() +		call space_vlaze#buffer#New() +		call space_vlaze#menus#Start() +	else +		" enew +		" execute 'b'  +	endif +endfunction + + +function space_vlaze#buffer#New() +	execute 'edit ' . escape(s:buffer_name, ' ') +endfunction diff --git a/autoload/space_vlaze/colors.vim b/autoload/space_vlaze/colors.vim new file mode 100644 index 0000000..f10901b --- /dev/null +++ b/autoload/space_vlaze/colors.vim @@ -0,0 +1,3 @@ +function! space_vlaze#colors#Initialize() +	 +endfunction diff --git a/autoload/space_vlaze/game.vim b/autoload/space_vlaze/game.vim new file mode 100644 index 0000000..ab721a1 --- /dev/null +++ b/autoload/space_vlaze/game.vim @@ -0,0 +1,53 @@ +function! space_vlaze#game#Init() +	let s:score = 0 +	let s:start_time = localtime() +	call space_vlaze#game#SetupWindow() +	call space_vlaze#colors#Initialize() +	call space_vlaze#game#InitializeBoard() +endfunction + + +function! space_vlaze#game#SetupWindow() +	setlocal bufhidden=delete noswapfile nolazyredraw +endfunction + + +function! space_vlaze#game#InitializeBoard() +	call space_vlaze#game#SetupBoard() +	call space_vlaze#game#RenderBoard() +endfunction + + +function! space_vlaze#game#SetupBoard() +	let s:board = [] +	let s:BOARD_HEIGHT = 20 +	let s:BOARD_WIDTH = 80 +	 +	" Create 20-row by 80-column board initialised with spaces +	let i = 0 +	while i < s:BOARD_HEIGHT +		let s:board = add(s:board, []) +		 +		let j = 0 +		while j < s:BOARD_WIDTH +			let s:board[i] = add(s:board[i], ' ') +			 +			let j += 1 +		endwhile +		 +		let i += 1 +	endwhile +	 +	" Initialise player to the middle of the board +	let s:board[10][39] = space_vlaze#player#PlayerCharacter() +endfunction + + +function! space_vlaze#game#RenderBoard() +	let i = 1 +	while i <= s:BOARD_HEIGHT +		call setline(i, join(s:board[i - 1], '')) +		 +		let i += 1 +	endwhile +endfunction diff --git a/autoload/space_vlaze/help.vim b/autoload/space_vlaze/help.vim new file mode 100644 index 0000000..7a1f8e9 --- /dev/null +++ b/autoload/space_vlaze/help.vim @@ -0,0 +1,4 @@ +function! space_vlaze#help#Show() +	help space_vlaze +	only +endfunction diff --git a/autoload/space_vlaze/mappings.vim b/autoload/space_vlaze/mappings.vim new file mode 100644 index 0000000..fdd2a37 --- /dev/null +++ b/autoload/space_vlaze/mappings.vim @@ -0,0 +1,9 @@ +function! space_vlaze#mappings#Initialize() +	nnoremap <silent><buffer><nowait> q       :call space_vlaze#game#Quit() +	nnoremap <silent><buffer><nowait> p       :call space_vlaze#game#Pause() +	nnoremap <silent><buffer><nowait> h       :call space_vlaze#player#MoveLeft() +	nnoremap <silent><buffer><nowait> j       :call space_vlaze#player#MoveDown() +	nnoremap <silent><buffer><nowait> k       :call space_vlaze#player#MoveUp() +	nnoremap <silent><buffer><nowait> l       :call space_vlaze#player#MoveRight() +	nnoremap <silent><buffer><nowait> <space> :call space_vlaze#player#FireBlasters() +endfunction diff --git a/autoload/space_vlaze/menus.vim b/autoload/space_vlaze/menus.vim new file mode 100644 index 0000000..90af0bb --- /dev/null +++ b/autoload/space_vlaze/menus.vim @@ -0,0 +1,21 @@ +function! space_vlaze#menus#Start() +	echo 'Welcome to Space Vlaze' +	let choice = space_vlaze#menus#Prompt( +		\ 'What would you like to do? (start game (s), view leaderboard (l), view help (h): ') +	 +	if choice ==? 's' +		call space_vlaze#game#Init() +	elseif choice ==? 'l' +		call space_vlaze#leaderboard#Show() +	elseif choice ==? 'h' +		call space_vlaze#help#Show() +	endif +endfunction + + +function! space_vlaze#menus#Prompt(message) +	call inputsave() +	let input = input(a:message) +	call inputrestore() +	return input +endfunction diff --git a/autoload/space_vlaze/player.vim b/autoload/space_vlaze/player.vim new file mode 100644 index 0000000..53583bd --- /dev/null +++ b/autoload/space_vlaze/player.vim @@ -0,0 +1,3 @@ +function! space_vlaze#player#PlayerCharacter() +	return '◆' +endfunction diff --git a/doc/space_vlaze.txt b/doc/space_vlaze.txt new file mode 100644 index 0000000..2d2724c --- /dev/null +++ b/doc/space_vlaze.txt @@ -0,0 +1 @@ +*space_vlaze.vim*	 diff --git a/doc/tags b/doc/tags new file mode 100644 index 0000000..c9b6ad9 --- /dev/null +++ b/doc/tags @@ -0,0 +1 @@ +space_vlaze.vim	space_vlaze.txt	/*space_vlaze.vim* diff --git a/plugin/space_vlaze.vim b/plugin/space_vlaze.vim new file mode 100644 index 0000000..257f715 --- /dev/null +++ b/plugin/space_vlaze.vim @@ -0,0 +1,10 @@ +if exists('g:loaded_space_vlaze') +	finish +endif +let g:loaded_space_vlaze = 1 + + +command! SpaceVlaze call space_vlaze#Start() + + +nnoremap <leader>sv :SpaceVlaze<cr> | 
