Monday 10 October 2011

Keeping track of thousands of objects


The image above is a cross-section of the randomly-generated map in Worldcrafter.  You can see tunnels, dungeons (some with floors of lava, mwah ha ha!) a lake and a lava river running along the bottom.  Other purple specks are things like monster generators, tangleweed and maybe even a chest of treasure.  It's pretty big, and yet the program has to keep track of a lot of the map blocks since they need processing to check if they should do anything, e.g. if they are water or lava, then flood.

The way the software does this is to have 3 lists of game "objects":-

1) Objects that need processing every game tick, e.g. a zombie.
2) Objects that don't need processing straight away but every few seconds at least, e.g. water blocks.
3) Objects that don't need processing until the player can see them.

So the first group of objects get processed every game tick, since it wouldn't do to have a zombie just stand there while the player throws rocks at it's head (although that might be realistic).  One or two objects from the second list are processed every tick since updates aren't as urgent.  And of the third massive list, one to two objects are checked every game tick to see if they are in range.  If they are, they are moved to the second list.

Easy peasy!  Look out for the new Worldcrafter update towards the end of the week.

7 comments:

  1. Whats in the next update?? Please add skeletons and more blocks to use and crafting table!

    ReplyDelete
  2. Skeletons will be in the next update. I'll be adding a crafting table as soon as I've decided what the player can do with it - suggestions welcome!

    ReplyDelete
  3. Ok cool! Make just one junp button above the right moving button. Then make skeletons drop bones witch you can craft iron and that bone to make a sword. And also see if you can add sheep for wool! Wool will be used to craft a bed with wood. You can also spawn where your bed is. These are my suggestions. Thaks for the time!

    Sincerly, manny333

    ReplyDelete
  4. Changing day / night is very fast. Can you make it slower? About 5 min. day and 5 min. night.

    ReplyDelete
  5. Areneo thats 100% true! Need to make the cycle slower!

    ReplyDelete
  6. Consider it done in the next release. Manny, thanks for the suggestions; there will be a big crafting update in the release after the next one.

    ReplyDelete