Newsflash

TerrainTypes working! PDF Print E-mail
Written by Stefan Hendriks   
Wednesday, 11 July 2007
I mentioned that terrain types are being built. And now they are in!

Imagine this, you have a bitmap with a grid of tiles. Like, when you download the Dune 2000 editor (Shai-Hulud 2000) , it has tilesets. These tilesets are big bmp files with 32x32 tiles in one big grid.

Now, lets say we create our own grid of tiles per terrain type. Rock, for example. In Dune 2000 you have varieties of rock graphics. So it won't look like one grid in the game (though it is).

In the engine this  problem is now solved (and yes, there is a screenshot in the gallery). Want to know how? Read further...
The rules and resources xml files really come together in this part.

The rules xml file specifies the screen resolution; the width, height and bitdepth (as mentioned before). But , it also specifies the width/height of the grid. You can only define sizes with the same height & width. Therefor, there is only one element called "tilesize". For dune 2000 graphics (and dune 2 - the maker) the tiles are sized as 32x32. So tilesize is 32.

The terraintypes on the other hand, need a bitmap so we know what to draw. This bitmap has a grid, just like Shai-Hulud 2000 (the editor for dune 2000). The difference is this:

1. One bitmap is one terrain type (so the entire grid reflects rock, sand, spice, whatever)
2. The X axis specifies the 'faces' of the rock. Meaning, it can be a filled rock, single rock plateau, or other graphic (an edge for example).
3. The Y axis specifies the varieties per Face.

The gallery shows a picture of rock, but the rock looks nice and randomly placed. It is using the Y axis, variety, to draw the proper rock tile.

Let me show the xml part of a terrain type:

<terrain id="TERRAIN_ROCK">
    <width>32</width>
    <height>32</height>
    <surface>BMP_TERRAIN_ROCK</surface>
    <passable>true</passable>
    <harvestable>false</harvestable>
    <credits>0</credits>
    <hitpoints>0</hitpoints>
    <destroyable>false</destroyable>
</terrain>

The terrain id is a unique id. Needed for your readability and for the engine to know it is a different type of terrain.
The width and height is the tile size for the specific surface given. This means you could theoretically have different sized tiles than the 'default' size of the grid.

Other properties are self-explaining.

Credits is the max credits a harvester can mine from the terrain type. So when spice is placed on the map, initially it can have max of <credits> (but lower, as it is randomly done). The terrain type needs to be specified a bit further, since i am not sure yet how to make smoothening work (probably with a fixed set of faces for the moment).

Anyhow. Things come together and it begins to show.

On top of all this, i have one final cool feature: D2TM originally had this sort off, but now it is improved: CPU time slicing.

Whenever the gained FPS is higher then the ideal fps, an amount of miliseconds will be calculated that was 'overhead' and given back to the cpu. Meaning, the duo-core pc at work only uses 5% of its CPU to show the engine. While my older beast at home takes 30%.

I want the 'ideal fps' being adjustable. So , lets say you're on a laptop and you're satisfied with 30fps. You give the cpu 50% more slack (since default is 60 fps atm).


Last Updated ( Wednesday, 11 July 2007 )
< Prev   Next >
Copyright 2000 - 2005 Miro International Pty Ltd. All rights reserved.
Mambo is Free Software released under the GNU/GPL License.