Thursday, October 27, 2011

Development Log: January Engine - Week 3


I took a break from working on the battle system to make an overworld map system.  I think that by working on both sections at once, I can bounce between them when inspiration strikes, and if I'm stuck on one I can just go back to the other for a while.

Colors!
Currently, the navigation system works as a grid where the player (the "P")  can move through empty spaces, but not into spaces with "X"s in them.  You use the arrow keys to move.

Ridiculous sidenote:  I wanted the player to be able to also use WASD controls, but there is something weird going on with keyboard commands in Flash recently, and it's not limited to just this.  It may be a Chrome bug or a Flash bug in general, but I find that whenever I play a Flash game, a host of problems occur when I try to use the letter keys, from the program thinking I'm holding down the button when I let go, to it thinking every key I press is the same key as the first I pressed, to the opposite problem where a single key changes to a new keycode every time I press it (so I press "wwww" and it comes out as "wert" etc.).  This nasty bug happens with every Flash program I use, so it basically makes WASD controls untestable, so I decided to just throw them away until Flash or Chrome or whatever the problem is fixes itself.  When this gets fixed, I will quickly add WASD controls to the engine.

Walking into an enemy (the things labeled "E1") causes a battle to occur.  When either the enemy or the player loses all their health, the battle ends.  (There is no game over screen yet, so even if the player loses, the player actually wins.)  Then the game goes back to the overworld, and the enemy is beaten.

The player can also move through the path to the left and end up on another screen.  The map system works kind of like the original Legend of Zelda, without the fancy scrolling.

And without the fancy... everything.
One bug to keep in mind is that the flash player needs to get the focus, so you need to click on the screen before you can use the arrow keys.  And for some crazy reason, you have to click every time you shift from one map to the next, which is a bug I'm still trying to figure out.

As for the coding itself:

I discovered the Vector data type, which is an Array of only one data type, while an Array can hold many data types.  Besides being more convoluted to declare, the Vector is less computationally intensive, I would have to guess, so most of the things I made as Arrays have been switched to Vectors.

Each individual map is a Vector of Strings, which gets created into the visual grid when the player moves into it.

To figure out which map to load as the player moves between them, I made a Vector of Vectors, which holds the smaller maps in order so I can just reference them by their location in the overall map.

I've got a few tasks to do for next week, including making the enemies move randomly around the map (or even follow the player to attack), making a game over condition, and fix a few battle bugs.  But the fun task that I'm looking forward to is making some NPCs with dialogue boxes that pop up when the player approaches.

No comments:

Post a Comment