Sat Nov 5 17:53:16 EST 2011

Z+ - Board Model

Before I start hacking away, I really need to think about what the data model for an individual board is going to look like. In ZZT, each world consisted of multiple 60x25 boards with links between them. I intend to relax the 60x25 restriction, allowing boards of arbitrary (but fixed) size.

I will probably store the contents of each board as an array, for the following reasons:

  • It's simple. When I consider anything more complicated, the twin principles of YAGNI and "do the simplest thing that could possibly work" both seem to apply."
  • Access and update for a given coordinate are fast.
  • Object density will be fairly high, so there won't be a lot of wasted space.

The next question to answer: what goes into each board cell? My first though was to have a background of arbitrary character and foreground/background colour, with a possible object on top. That hits a wall when passages are considered.

For those who don't remember, a ZZT passage is an object, that when touched, transports the player to a destination board (either to a passage of the same colour, if it exists, or to the location of the player object on that board). I want to keep multiplayer in the back of my mind as I write Z+, so a player cannot instantly disappear into a passage if it's occupied by someone else. Therefore, I will replace the inert background by second layer of objects, to represent things like floor spikes, passages, lava and so on.

This means that each board has two layers of objects: foreground and background. I am strongly against adding more layers - simplicity is a design goal!. So long as it is cheap to create and store inert objects (that is, objects without code), I see no problem with this approach. Solid walls were going to be objects without code anyway.


Posted by Jack Kelly | Permanent link | File under: zplus, coding