Log in


maffyew in z2kdev


I decided that this week would entail a short break from studying C#.NET to play around with TorqueScript and see if I can get some very basic framework happening for Z2K. I justified this diversion by telling myself it's still coding. :P

I wrote out a short six point "wishlist" of little simple things I could put together into one package - enough things to ensure I would not run out of stuff to work on, but mainly to see if I could do it on a smaller scale:

  1. A 50x50 game world grid with a player character that can move around it in the eight cardinal directions. The game world does not wrap, it ends at the edges and players should not be able to move beyond this point.

  2. Add in impassable squares. Players should not be able to move into these squares.

  3. Add in a “zombie” character. This will have very basic AI that makes a beeline for the player. It will not take obstacles into account, but will not be able to move through them either.

  4. Ensure the code works with multiple zombies.

  5. Give the player character and the zombie a couple of basic “stats”. Speed and Health. The player character moves roughly twice as fast as the zombie character and this should be reflected. If the zombie touches the player, the player loses health. When player's health reaches zero, the game ends.

  6. Refine the “combat” engine. Generate an algorithm based on chance to hit and body locations. Let the player “touch” the zombie now to fight back.

I'm pleased (and surprised, given my initial frustrations with TorqueScript) to say that I've managed to do the first four in a day and a half. I have a method I can run from a console that generates more zombies on the fly, and they all move one tile toward the player every time he makes a move in any direction, or passes a turn. Neither the zombies or the player move through walls.

However, the pathfinding algorithm I've bashed together is shocking, essentially it just looks at the x,y coordinates for each zombie, compares them to the player's coordinates and moves the zombie directly toward the player - this results in ugly behaviour like zombies getting "stuck" on a wall to its southwest when they should just move south instead of trying to go southwest... (zombies might be dumb but they're not quite that stupid) but I'll be looking to refine it further down the track once I have some more of the basics out of the way.

I have a few ideas as to how to achieve the last two, but it's going to need some more research into the "datablock" structures that TorqueScript uses to see if they're the best way of storing variables for individual objects.

Here's some programmer art, for funsies:

Originally I was going to just draw a blue stick figure for the player and a red stick figure for a zombie that I could use in game, but once I get MSPaint open, I just can't help myself. :P


This is a repost from my personal journal. The original post and comments can be found here: http://maffyew.livejournal.com/310143.html



March 2007

Powered by LiveJournal.com