Worklog for AaronK

Worklog 1

Return to Worklogs

Initial state(Posted 2004-12-02)
----------------------------------------------------------
NOTE: There are no BlitzMax specifics in here it's all Blitz language neutral so don't expect to find any leaked info here.
----------------------------------------------------------


I've been lucky enough to be on the BlitzMax Beta team for a short while, and one of the things I wanted to do was rewrite my AStar algorithm that I wrote a long time ago in the old Blitz2d. This time though, my AStar stuff is in a nice, reusable module, so anyone will easily be able to use it with only a couple of lines of code - When BlitzMax is out of course!.

To prove it's reusability I decided to redo the Loderunner conversion that I did originally with the old Algorithm and I was very suprised at how easy it was to reuse the AStar code, so I'm happy about that part.

Originally I was just going to convert the old code, and plug in the new AStar and a few days ago someone kindly found me the original Loderunner source to do this with (I'd lost mine). Unfortunately, I tried to convert it to BlitzMax but it was proving too time consuming and on top of that the old code was not Object Oriented. So I thought a rewrite would be a good thing to do.

Progress is pretty good at the moment and currently I have:

- The maps loading and displaying correctly.
- You can run around the map
- You can dig
- The enemy can chase you around the map
- Enemy can die in holes
- Level Finished condition works (Hidden ladder appears)

There is still alot to go, as the old version had a demo mode, built in editor etc. Also there is quite a bit of tweaking that will need to be done to get things feeling "original" and tight.

Problems
--------

** Blocked based systems

I've always found writing block based games frustrating. Trying to write an elegant system for handling all the myriads of collision combinations with various parts of the game has always seemed elusive and I'm never entirely happy with the result. Tweak one thing and other parts of it seem to change. In a game like Loderunner, you have to handle situations like

- Falling and landing on blocks
- Landing on enemy heads
- Landing and moving along bars
- Enemies climbing out of holes and not falling straight back in
- Player running over enemy heads
- Ladder climbing
- Not walking through some blocks
- Walking along the ground where there is no block below you (bottom of map)
- Not diging outside the map boundaries

Now I agree most of these are easy to do, but the resulting code just seems somewhat messy to me. I'm sure there must be a better way to model a block based world than what I normally do which is write specific condition handling code. Ahh well, just a pet concern of mine...

** Enemy movement
This is where I stray far from the original Apple ][e version in that I'm pretty sure they didn't use the A* pathfinding algorithm to do their enemy movement. Of course, this is the reason I wrote the game so I'm not changing it but it does have it's problems - mainly that it's too good. Some of the things I have implemented.

- The enemy only looks a short way ahead of itself when looking for you. This means that they can hardly ever (Unless you are very close) find the perfect path to you. This was a easy as passing a "MaxNode" value to the pathfinding algorithm.

- Once an enemy has found a path it will follow it and only look for you again when they reach the end, or a predetermined time has elapsed. This works pretty well in dumbing them down because in Loderunner the player is usually running around a lot.

- Related to the above, the enemies don't have to recalculate their paths often which means less CPU time used for AStar. And the distribution of the enemies doing this means that they generally don't generate their paths in the same game update loop.

- I use a simple distance calculation. Makes it faster and less accurate

- One little thing that you have to worry about is that the enemy should only change direction on a block boundary. Specifically this is for ladder climbing. I had a wierd bug where what was happening was that the enemy was trying to go up a ladder but wasn't directly under it, so it was effectively hitting it's head on the block above and not moving.


Enhancements
------------

** Model/View
One of the enhancements I'm doing to this version is to separate model and view some more. This way I can plug in different views as I always wanted to do a version of Loderunner that used actual 3d models - still side on, just 3d. Keeping the model and view separate means I should be able to plug the bits in quite easily when I get around to it.

** Difficulty
I might add in difficulty which, in my version could amount simply to making the pathfinding better on the higher difficulties and generating paths more often.


-----------------------------------------
P4 3Ghz, Matrox G550, 500Gig HD space.

"But don't you know how old I'll be before I really learn to Paint/Write/Act?"

"Yes, exactly the same age you'll be if you don't"