aboutsummaryrefslogtreecommitdiffstats
path: root/autoload/space_vlaze
AgeCommit message (Collapse)Author
2015-10-21help.vim: Use `space_vlaze.txt` instead of `space_vlaze.vim`HEADmasterTeddy Wing
Forgot to update the built-in menu's way of bringing up the help when I updated the main help file tag in 8606ac8ce8e7d872da5b77e644fd32ac4c7fd26b. This way, entering `h` in the game's main menu will correctly bring up the plugin's help documentation.
2015-10-08help#Show: Open help for `space_vlaze.vim` with the extensionTeddy Wing
To ensure that the help file opens at the top. Otherwise for some reason it was opening at *space_vlaze-h* for me.
2015-10-08leaderboard#Sort: Convert inputs to numbers before comparingTeddy Wing
Otherwise the inputs get compared as strings and only the leftmost digit of the number gets sorted so you end up with things like this: [8, 43, 2, 13, 0] Convert our inputs to numbers so that they get compared in their entirety and larger numbers move to the head of the list.
2015-10-08mappings#Initialize: Change mappings to `<nop>`Teddy Wing
Since we're handling game actions in `mappings#Listen()` now, don't call our functions from these normal mappings. The reason for not doing so is because otherwise after you get a Game Over you could still move the player around and fire missiles (although doing so wouldn't affect your score). Set these keys to `<nop>` so that they don't do their normal Vim functions so we can maximise the feeling of being in the game world versus being in a text editor. Otherwise you can move your cursor around, record macros with `q`, and I'm just not sure I want to allow all that in the game.
2015-10-08Play audio when player hits an enemyTeddy Wing
Generated with Cfxr.
2015-10-08Add audio for missiles firedTeddy Wing
Generated with Cfxr.
2015-10-08Add audio for player movementTeddy Wing
Again created with Cfxr. (Godsend!)
2015-10-08Add "enemy defeated" soundTeddy Wing
Generated with Cfxr. Play a sound when an enemy is destroyed. Sounds are located in the "Resources" directory. Audio is played using `mplayer` if available.
2015-10-08menus#Start: Call `leaderboard#RenderLeaderboard()` on `l`Teddy Wing
When pressing `l` call the new name of the function we're using to render the leaderboard as the original one I had put here was a stub.
2015-10-08leaderboard#RenderLeaderboard: Show headline and scoresTeddy Wing
Output our "Leaderboard" header. Two lines needed to be surrounded in double quotes since they contain single quotes and backslashes needed to be escaped in those strings. Output player name and high score value. Not very pretty unfortunately. Using hard-coded left padding where it would be nice to calculate padding needed to center the name and score. Also would like to right-align score numerals but leaving it as an enhancement as there are more pressing things to do for now.
2015-10-08leaderboard#RenderLeaderboard: Run window setup function from game.vimTeddy Wing
Set the same buffer-local window settings that we set for the game so we can control the look and workings of things.
2015-10-08leaderboard#RenderLeaderboard: 2 font choices (WIP)Teddy Wing
Start of render function, initialising a new buffer for the leaderboard and getting necessary data from our storage files. Two font options generated from Figlet, one in "cybermedium" and the other in "larry3d". Going to go with the "larry3d" one.
2015-10-08Save high scoresTeddy Wing
When you get a game over, save your high score to a file so that we can display it on the leaderboard. The saved scores get sorted from highest to lowest. If we don't have your name yet (saved to a separate file), we prompt you for it. This means that you can only have one player (name) per installation. Not the best scenario because maybe you have multiple people playing on your computer, but I made a judgement call to do it this way so we don't have to keep prompting the player for their name every time they get a Game Over. That could get annoying fast.
2015-10-08colors#Initialize: Set background coloursTeddy Wing
Set the background colour for the game board to be my normal colour scheme's background colour so that people with other colour schemes can see the game with the full set of colours I've been working with. Set the foreground colour to white to allow it to be readable over the dark dark grey background (otherwise we wouldn't be able to read the "Game Over" text).
2015-10-08Add space padding to Lives and Score linesTeddy Wing
Pad these 2 status lines with spaces to the right of their string values so that their background colours extend to the full width of the game board. First tried `len()`, then `strlen()` when counting characters in `padding#RightPadding()` but turns out those deal with bytes and the player character is a multi-byte character so we would come up sort on spaces for padding in the Lives line because the player diamond counts for double. To get around this, used `strchars()` which gives us a count of the characters instead of the bytes.
2015-10-08life#RenderLives: Add space between `|` and diamondsTeddy Wing
Add a space after the `|` pipe character we added in c9934c4b1192f50ae0d6930381622c58fbe7048a to put some breathing room between it and the diamond characters. Went back and forth on this and neither looked quite right but I think I'm going to go with this one.
2015-10-08Add coloursTeddy Wing
* Need to hard-code the enemy and player characters in order for the `syntax match` calls to work * Enemies are a brownish colour (to remind you of popcorn kernels) * The player is a pinkish colour because it's vibrant and contrasts with the brown of the enemies * Lives have a maroon/burgundy background colour * Score has a purple background colour that's similar enough in shade to the lives section to make it part of the same context but different enough to make it it's own section * Add a `|` pipe character in front of score in order to be able to colour it correctly even if the player has 0 lives left.
2015-10-08game#SetupWindow: Flesh out buffer settingsTeddy Wing
Base window/buffer-local settings on: https://github.com/mattn/invader-vim/blob/f04e7f5e8ac42ae87db6050e64449055206c4054/plugin/invader.vim#L181-L189 Gives us a clean environment to display the game in.
2015-10-08buffer#Init: Remove commented call to game#Init()Teddy Wing
We do this in `menus#Start()` so there's no need for this.
2015-10-08mappings#Listen: Show "Game Over" screen on `q`Teddy Wing
When pressing `q`, in addition to quitting the game also display the "Game Over" screen. Without this, when you quit the game the board would stay the same as it was just before pressing `q`. It seemed kind of confusing not to have any feedback that you quit the game so I figured I would do this to at least let you know that you successfully quit the game.
2015-10-08buffer#Init: Allow players to start a new game in the same sessionTeddy Wing
Don't prevent the menu from showing up on subsequent invocations of `:SpaceVlaze`. This allows us to start multiple new games in the same Vim session.
2015-10-08buffer#Init: Use existing Space Vlaze buffer if availableTeddy Wing
Don't create a new Space Vlaze buffer if one already exists.
2015-10-08game#GameOver: Re-center "Game Over" textTeddy Wing
Re-center the text since I added spaces between the letters.
2015-10-07game#GameOver: Add a descriptive comment about what the math is forTeddy Wing
2015-10-07Create "Game Over" stateTeddy Wing
When the player has 0 lives left then quit the game and display "Game Over" text. TODO: Request player name at this point to store in the leaderboard.
2015-10-07Decrement player lives on collision with an enemyTeddy Wing
Additionally extract `IsEnemyAtCell` function that determines whether an enemy is located at a given cell.
2015-10-07Add livesTeddy Wing
* Create life.vim to keep track of lives * Players start with 3 lives * Add increment and decrement functions for lives because they'll be useful in the future (although there's a more immediate need for the decrement function) * Render lives at the bottom of the board * Move the score line down so that it appears just below the life count display
2015-10-07Increment score when enemies are destroyedTeddy Wing
* Create score.vim to keep track of score and group scoring-related functions * Increment player score when an enemy is defeated. The point count is based on a base value and a multiplier. Currently set to 1 for each such that each enemy is always worth 1 point. The multiplier is there so that as time increases we can increase the multiplier and increase the value of an enemy the longer the player plays. * Render score to the screen so that it's visible to players.
2015-10-07missile.vim: Stop missile when it hits an enemyTeddy Wing
Instead of traversing the whole board and continuing to hit enemies along the way, ensure that missiles stop when they hit their first enemy. This restructures the loop such that each missile acts independently of the other three.
2015-10-07Hitting enemies with missiles makes enemies disappearTeddy Wing
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.
2015-10-07game.vim: Create `ClearBoardCell` functionTeddy Wing
Sets a board cell at a given set of coordinates to ' ' (space). This allows us to call this new function from `ClearPlayerCell` instead of having to pass in the empty cell string. We need this function to be able to clear an enemy from the board when it gets hit by a missile.
2015-10-07enemy.vim: Add descriptive comment to DropEnemyAtRandomCoordinatesTeddy Wing
Explain the while loop and condition here better than the code explains it.
2015-10-06random.vim: Use :rubyTeddy Wing
Since `:python` didn't work out for me because of my system version mismatch (1307eac), use Ruby to generate random numbers instead. And w00t! this doesn't block the interface, rendering, and player movement!
2015-10-06random.vim: Use :pythonTeddy Wing
Ostensibly this should work and generate us a random number using Python without having to call `system`. My hope is that this call doesn't block rendering and execution of our game. The trouble is that I can't get it to work because I have Python 2.7.1 installed as my system Python (which Vim is linked against), and Python 2.7.9 installed via Homebrew. Vim is looking in the Homebrew path when it should be looking in the system path to Python and causing this error: Error detected while processing function space_vlaze#random#Random: line 7: Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 47, in <module> from os import urandom as _urandom ImportError: cannot import name urandom More information: - https://github.com/klen/python-mode/issues/87 We could get around this by not having these 2 versions of Python installed on our system (the random implementation changed between 2.7.2 and 2.7.3) or by setting `$PYTHONHOME` in our vimrc. Could, but I'm sick of this shite. Would have liked to be able to use Python for this because in my opinion Python tends to be pretty fast as interpreted languages go, but frak it I'll just use Ruby.
2015-10-05Add enemies to boardTeddy Wing
Add a bunch of enemies to the board. The count will depend on how long you've been playing the game. This currently kind of works in that it adds enemies to the board at random coordinates and adds more as time goes on (too many actually, I'll need to reduce the count or slow down the spawn rate). The trouble is that it looks like it's blocking on the `system` call to `python`. This is a problem because it freezes the board and prevents any player movement while the Python random command is working. Let's try using Vim's built in `:python` to do this to see if that makes any difference. game.vim: Add a `ticks` script variable that tracks clock ticks and increments each time our game loop executes. This will allow us to keep track of time in a consistent way and make it easier for us to pause time when we pause the game. Also, I envision it being easier to deal with smaller numbers starting from 0 instead of a whole Unix timestamp. Got the idea for ticks from Tetris.vim (http://www.vim.org/scripts/script.php?script_id=172) enemy.vim: * Set player character to a spade (like in playing cards) because when it's small it could kind of look like a popcorn kernel * Set a min and max amount of enemies that can be on the board at any given time because we don't want a sparse board and we also don't want to overwhelm the player when they've been playing for a long time and the spawn count increases to an insane amount. * Create a function that will drop an enemy at random coordinates on the board not on the player's coordinates. TODO: we should extend this function to ensure enemies can't spawn within a certain radius of the player so that we don't get random instances of being a dick. TODO: also ensure that we don't place an enemy on top of another enemy or on top of a missile. * Every 5 seconds update the enemies on the board and regenerate them such that the enemy count is withing the min and max enemy counts.
2015-10-05Add random.vimTeddy Wing
Add a random number generator based on this Stack Exchange post from Carpetsmoker: http://vi.stackexchange.com/questions/807/how-to-generate-random-numbers/812#812 Since Vimscript doesn't have a random number generator, shell out to Python and get a random int between 0 and the max value passed in.
2015-10-05missile.vim: Fire all 4 missiles even if one hits the edgeTeddy Wing
Fire all 4 missiles and make sure they continue moving until all 4 of them hit the edge instead of stopping when a single one hit the edge of the board.
2015-10-05missile.vim: Fire all 4 missiles (WIP)Teddy Wing
Fire all 4 missiles at once. Currently doesn't work and stops when one of the missiles hits the edge of the board.
2015-10-04missile.vim: Clear missile when it gets to edge of boardTeddy Wing
Remove missiles when they get to the end of the board. Otherwise they just stay there right before the end.
2015-10-04Add right missile (WIP)Teddy Wing
Create a missile moving to the right of the player. Pressing <space> fires the missile. Later we'll want one coming out of each direction, but this is just to test it out. TODO: * Clear missile when it gets to the edge of the board * Make it so the missile doesn't block other actions on the board (including player and enemy movement)
2015-10-04game.vim: Move `redraw!` into `RenderBoard()`Teddy Wing
We will always want to `redraw!` when we re-render the board, so call `redraw!` from inside this function. Noticed this when I was writing the missile firing code and realised that I needed to re-render the board at each step in the missile animation.
2015-10-04mappings.vim: Use ` ` instead of `<space>`Teddy Wing
Because `nr2char` gives us an actual space character instead of `<space>` as I had thought given the examples I had seen of it.
2015-10-04Make player movement workTeddy Wing
* Store player coordinates in `player.vim` instead of `game.vim` because they belong to a player instead of the game/board so it makes more sense to store them there. * Remove old player functions from `game.vim` * Update movement functions to ensure that they update the player coordinates in addition to updating the board array
2015-10-04Add player movement (WIP)Teddy Wing
Kind of add player movement. TODO: Update player coordinates when moving * Add a main game loop to `space_vlaze#game#Init` * Fill in player directional movement functions * game.vim: Add functions to access and set `s:` variables so these can be accessed from player.vim * Add new mappings based on https://github.com/mattn/invader-vim/blob/f04e7f5e8ac42ae87db6050e64449055206c4054/plugin/invader.vim#L44-L60 because it turns out that the mappings we previously defined don't work when out main loop is running.
2015-10-04game.vim: Save player coordinates to script globalsTeddy Wing
These aren't constants so maybe they shouldn't be in all caps but wanted an easy way to know the current coordinates of a player. This should make player movement easier.
2015-10-04Connect in-game mappingsTeddy Wing
* Remove `<nowait>` since it isn't available in my version of Vim (7.3 2010 Aug 15, compiled Jun 20 2012 13:16:02) and breaks the mappings if it's included. * Create function stubs for all mappings * Add missing `<cr>`s to end of mappings to make them work * Initialise mappings when starting a game
2015-10-04game#SetupBoard: Use constants to initialise player to middle of boardTeddy Wing
2015-10-04Initial commit. Initial menu and board stateTeddy Wing
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.