Doomdark’s Jigsaw Puzzle

The Moutain Ranges...I’m going to post a few blog entries regarding technical issues in the Doomdark’s Revenge frontend for TME and TME itself. I wanted to talk about some of the more interesting things that are going on inside it from my point of view. It will help to give an insight but maybe also fill the void of no product!

1 – Patches
The base graphic system is built on the concept of ‘patches’. A patch is a graphic xml file format. It holds instructions on how to draw various graphics based on other graphics. The idea for the system came from my interview with Mike Singleton for Retro Gamer. In it he talks about displaying the terrain for Eye of the Moon using component parts, allowing for a more varied landscape. So when I started on DDR, I thought; why not…

In it’s very simplist form a patch would just hold the filename of the actual graphic to use in order to display the patch.

[patch id='MAP' x='0' y='0' ]
    [image file='terrain\map\t2_forest8.tga' /]
[/patch]

Now getting more complex the patch can reference another patch and also more crutially reference variables. So it can decide to include a graphic or patch depending on conditions that have been setup prior to the patch being displayed. If we used the simple example of scale, the patch file can choose different images to display depending on what scale we wish to draw the graphic at. This allows for the effect of mip-map rather than allowing the graphics device to scale the pixels. This might mean that you get a better finish on the graphic, however, in most of the cases in DDR, this means we can subtly change the image because, a smaller scale usually means further away, and thus we can apply some form of distance effect to the image in pre-production rather than at post.

[patch id="_default" ]
    [image file="t2_forest0.tga" scale="1.00" var="6" value="0" /]
    [image file="t2_forest0.tga" scale="0.70" var="6" value="1" /]
    [image file="t2_forest0.tga" scale="0.45" var="6" value="2" /]
    [image file="t2_forest0.tga" scale="0.37" var="6" value="3" /]
    [image file="t2_forest0.tga" scale="0.28" var="6" value="4" /]
    [image file="t2_forest0.tga" scale="0.21" var="6" value="5" /]
    [image file="t2_forest0.tga" scale="0.17" var="6" value="6" /]
    [image file="t2_forest0.tga" scale="0.13" var="6" value="7" /]
[/patch]

This patch uses the same image but scales it depending on the size variable.

Some of the variables that a patch has access to are…

  • Var[1] is used for exit type. 1 = manmade, 0 = natural
  • Var[2] is used for movement step. currently 0 or 1
  • Var[3] is used for tunnel type. 1 = manmade, 0 = natural
  • Var[4] direction 0 – 7
  • Var[5] dir north & east = 1 south & west = 0
  • Var[6] size 0 1 2 3
  • Var[7] domain
  • var[8] domain % 10
  • var[9] terrain
  • chance%
  • By working with these variables we can display the same patch file, but allow the patch file to decide how it should display itself. So for example in the tunnels the patch would check the direction vars to decide if a patch should be on the left or right of the screen. Thus giving the correct affect of looking up or down a tunnel. It might also use the domain variables to decide a look for the graphic; it might display beams in the tunnel for particular values of domain.

    [patch id="VIEW"]
        [patch id="forest-leaf" var="8" value="2" cond="< " break="true"/]     [patch id="forest-leaf-pine" var="8" value="7" cond="<" break="true"/]     [patch id="forest-pine"/]     [/patch]

    This tree patch uses the domain%10 variable to decide on the type of forest that the patch belongs to. Here we have 3 types of base forest type. This makes the forests on the landscape different depending on where on the map you are.

    A patch also has its own random no which is used for the chance% variable, this random is seeded to a value specific to the use of the patches. For terrain patches this is based on the coordinates at the domain. What this means is that every time that patch is drawn for a given location, the random no sequence will always be the same. This allows a patch to behave differently from an adjoining location, but always the same at the same location.

    [patch id="VIEW" ]
        [patch id="mount-small" chance="15" break="true" /]
        [patch id="mount-very-big" chance="15" break="true" /]
        [patch id="mount-small-medium" chance="30" break="true" /]
        [patch id="mount-big" chance="30" break="true" /]
        [patch id="mount-medium" /]
        [/patch]

    This patch is for a mountain. You can see hat there is a 15% chance of the mountain being small, 15% chance of very big, 30% chance of small-medium, 30% chance of big, otherwise it’s medium. What this does is make sure that a single moutain is not always the same size. You could check the domain an have a graphic without snow or have all mountains in a particular range being the same size.

    Now as these patches break down further we can use it to build up parts of the image itself and not just choose what image to display. If you click on the image of the moutains you will see that there are 10 different images used to make a mountain. We use either ‘base’ or ‘small’ to start with, but overlay any or even all of the component parts of the base image to create a multitude of mountain types. Because a patch can reference a patch, then very complex sub routines of patches can be developed and then called upon randomly to build up the images. So if you break the image down to many smaller parts, then the final result can be very complex and have a tremendous amount of variations, but the patch code can be relatively simple. By using the numerous variables at our disposal we can make sure that the mountains of the Icemark are very varied without too much effort, or too many graphics.

    To me, this is one area that is very exciting for Doomdark’s Revenge. It means that the landscape becomes very rich and varied and removes the monotony of seeing the same terrain over and over again. The same system can be used for people…

    Technorati , ,

    Related Posts:

    5 Replies to “Doomdark’s Jigsaw Puzzle”

    1. DDR under the midnight engine is currently under development. The backend ddr engine is almost complete to be handed over to both TME and WOTS.

    Comments are closed.

    %d bloggers like this: