Engine guts.

Since I’ve already been working on my engine for a few months of on/off, lazy work, I’ll just give a small update on what’s going on inside up until now.

My first task was doing collision detection/response of course. The engine is based on circles and lines, with no support for more complicated figures. My goal for a future version is to have better collision response and more dynamic detection (I’ve only got the bare minimum to keep stuff from going through walls).
One thing I’m happy about is that the calculations are totally perfect. It’s impossible to have tunneling with any figure as collision detection is done by trimming a shapes movement vector until it no longer collides with anything (there’s a simple resolution phase where it pushes shapes out of other shapes automagically).
There’s a problem with squeezing, where if you try to move a circle between 2 lines that eventually become too narrow for it to pass through, the circle will go over one edge (to do with the resolution phase mainly).

After I was happy with my collision engine, I started doing things in the wrong order, and setup my lighting engine. I had an old prototype of this sitting on my desktop, so getting it up and running was a matter of extending old code. New features in this engine though are the gradients (pre-rendered bitmaps), and circle shadow support. I plan to give the zombie game a heavy horror influence, so lighting as a result will play a considerable role in the gameplay (zombie AI will respond to the player’s flashlight).

Parallel with lighting, I began working on the zombie AI (which is about half done, depending on how many more fps I’ll be able to squeeze out; future plans are having them react to light, and react to each other (if one sees you, then other zombies who see that zombie will follow him)). The zombie AI is quite simple. It depends on a node network, which isn’t my vision for an ideal AI, but it will do for this game. Wandering is simple: Zombie finds his nearest node. If that node is far away, he first travels to that node, otherwise directly proceeds to the next step, which is finding a random connecting node (this is one thing I plan to change, or at least constrain in some way just so that the movement doesn’t seem so random).
As soon as the player is in sight, the zombie will directly follow him. Upon losing sight, the zombie subtracts the players movement vector from his last position that was seen, and goes there. Then, it finds the closest node to that point. If that node is nearby, the zombie proceeds to the next step, otherwise adds the node to the zombies target list. Next, it compares all the node’s connecting nodes with the player’s last seen movement vector, so that it follows the player somewhat. The next step which I haven’t implemented yet is for the zombie to further add the nearest node from his last node, since when running away, players will usually take many short paths to lose sight of the zombie as quickly as possible.

So far that’s what’s going on. With shooting I’m just raytracing through the obstacles and zombies, and adding another light source over the gun.
I can’t promise frequent updates, but upon serious feature adds, I’ll most probably write up a blog post explaining them.

Enjoi the alpha engine!

2 thoughts on “Engine guts.

  1. Hey!

    You can see the current engine (an old build) here: http://psvilans.wrongbananas.net/projects/
    Nothing of the lighting engine has changed since, save for a few optimizations.

    I haven’t had a chance to continue working on the project in the past while, but hopefully I’ll get back on track in a week or so!


Leave a Reply

Your email address will not be published. Required fields are marked *