Sunday, December 18, 2005

Cave Drawings

So here's the plan. What I want to do for my first piece of code is create a rudimentary random cave generator whose results can be rendered to a simple bitmap. I want to be able to create an image (2 colors probably -- black and brown) that resembles the tunnels you might find in an ant farm.

To that end, the diagrams you saw in the last post represent my first approach toward the objects that I'm thinking about for implementing this project. I'm a big believer in designing complex even if results are simple, 'cause that usually makes for the most reusable code, which leads to quicker development over the long term.

The composable tiles thing could be tricky. By having every tile in the game potentially comprised of other tiles, and every tile itself potentially a member of a greater tile, I hope to have a tile / map architecture that allows the following features:

  • Pseudo-fractal map expandability: while a traditional tile-based map is limited in 2 dimensions by the coordinates describing the tiles' positions, adding this other dimension (the w axis, let's say) lets me describe any tile as being located at some offset within a parent tile's coordinate space, which in turn is located at some offset within a parent tile's coordinate space, and so on. Everything can be described as offsets of offsets, with the only "anchor" being the highest-level tile that has no parent. If the space afforded by that tile is exhausted, then just add a parent.
  • Neat zoomability: I always liked Black & White's ability to seamlessly zoom from a view of the entire land to a few blades of grass. While I can't yet figure out what kinds of interesting details can be found by zooming into a Metroid-flavored tile, I may think of something later. I could potentially have some kind of computer console in the world that, when zoomed in far enough, presents a real-time view of the immediate sector's map -- tiles within a tile.
  • Elegant serialization of map sectors: if a tile is capable of serializing itself, then nests of tiles can be serialized by ensuring that a tile's serialization algorithm also serializes all its subtiles. This kind of serialization remains flexible. Serialization strategies can be attached to entire branchs of the "tile graph", with some strategies suited for in-memory serialization / caching and others suited for persistent storage when the game is saved or loaded.
  • Interesting rendering possibilities: related to zoomability above, cascading tile drawing by having parent tiles also invoke child renderers could be useful.

This will be a fun little experiment. I found a great page on maze generation algorithms and am anxious to discover the best framework that will make not only random generation possible, but also the inclusion of prefab elements. For example, I'd like the ability to create a church room (say, a screen big) with specific decorations and whatnot, then register that room with the engine in a way that causes the engine to insert my hand-made church in the otherwise randomly-generated map if some condition is met.

Here are the sub-tasks for this project:

  • Create a geography generator that operates on tilesets (blank canvases) that I specify.
  • Apply a rendering system (got something up my sleeve here) that turns the modified tileset structure into a bitmap that can be painted onto a Winforms app.
  • Try to extend the tech demo so that the user can pan the map and see more geography generated in real-time, while simultaneously commiting existing tiles to persistent storage.

Here's a reasonable question: have I designed enough of the game (gameplay, story, etc.) to go this far in implementation? Probably not. Knowing exactly what features I want in the game -- having an itemized list of gameplay elements -- that would be the best blueprint for building code. But here's the thing. This is a hobby, and I (along with ZMan, apparently :) am itching to see something that actually does something.

My philosophy is this: Vyde as a game is far too big to design all in one go. I set out on this journey with every intention of letting the project grow organically. To that end, this map generator is a prototype. It's a proof-of-concept tech demo that I believe will serve to give me a better idea of what my limits are and tune me to a more focused direction later on.

Let the game begin!

0 Comments:

Post a Comment

<< Home