Question about RTS's

Started by
11 comments, last by GameDev.net 24 years, 5 months ago
If you only have/allow 1 building (or buidling segment) per map cell, you could include the building (or a pointer to it) in your map cell data structure.

You would still need to draw the terrain background before drawing the building on top of it.

I have an article submitted to GameDev about "base data structures" for RTS-style games. Hopefully that will be up in a few weeks.

------------------
DavidRM
Samu Games

Advertisement
Presumably a lot of your buildings will be larger than a single tile, and you will probably want them to be destructable (or even moveable, like StarCraft). You will also want correct Z-ordering. Hence buildings should probably be unit-based, for easier management, even if they are tile-aligned.

Let's say I have square tiles, each 32x32 pixels, like
the old Warcraft game. And one building is placed in
the middle of 9 tiles, 3 tiles wide x 3 tiles high. How
exactly is the building image stored and drawn? Let's remove
the concept of units for the moment and just focus on the
ground and buildings.

I can think of two ways:

1. Everything is stored as 32x32 pixels. This means the
buildings are cut up into 32x32 pixel images with transparent
outlines to let the background show through when blitted.
For each tile, the background is drawn, and then the corresponding
building section is drawn on top. This is drawn together
in one sweep.

2. Only the background is stored as 32x32 pixels. The buildings
are stored as full images. So in this case, this building
would be stored as a complete 96x96 pixel image with a transparent
outline. The full background is drawn first in one sweep,
The the buildings are transparently in a second sweep.

Which way is better and are there other ways of doing it?

Reaver

My guess would be the second option, becuse it's less of a pain to not have to cut up and your images, and because it's less blits. You could still hold the data in the map structure in a 3X3 section with out cutting the tiles up.

------------------
--Orion McClelland

Write more poetry.http://www.Me-Zine.org
Does the 2nd method applys to both RTS and
RPG type of games? And how do we actually
implement it? Will it slow down the blt?
For buildings that are 96x96 in a 32x32 tiled world, I would have the first sector of the 3x3 tile to hold the graphics info like the width and the height. Everything else that the building coverd should be NULL because that space is occupied. Looping through the array from left-right-up-down would produce correct results. The building would be drawn where the info is. Everything that is nulled should be skipped.
A 3x3 building placed in a 9x9 map.xxxxxxxxx // x = tile junkxINNxxxxx // I = building infoxNNNxxxxx // N = NULLxNNNxxxxxxxxxxxxxxxxxxxxxxx

For the isometric view, have it at the end of the tileset so everything behind the building would be overlapped.

[This message has been edited by Ðragun (edited November 03, 1999).]


I also agree I prefer drawing the full building (even if it covers more
than one tile) in one blit, because you might want to move them around
like in Starcraft, or do some kind of neat alpha effects on the whole
image.

But I don't think I would want to store building data in the tilemap
itself (is this what you are doing Dragun?), since most tiles on a large
world map will be empty background tiles. Maybe a separate building
list would be better.

Reaver

I was refering to the declared situation Reaver. I would have done it entirely different.

[This message has been edited by Ðragun (edited November 03, 1999).]


When you say NULL, are you referring to a struct pointer of building
info that is dynamically allocated and deleted when not needed?
Or are you referring to variables that are fixed in memory
like an array that are NULLed out and not used?

A lot of people here seem to use their own terminology when
referring to tiles, cells, sectors, etc., so just to clearify
myself, when I say tilemap, I am referring to an 2D array that
only contains the background or ground tiles.

I'm sure there are lot of ways to do it, so I'm just looking for
the way that works best for my situation too.

Reaver

Hell. When I wrote 'NULL' it meant undefined. Also, storing building data directly inside the tilemap (an array of a structure that defines a single map cell) is perfectly fine. When the hell would there be two instances of a building on one given tile cell? It's a RTS! But then I would just have a background tile and and list of entities (mask layer, objects, etc.) ordered by z value.

This topic is closed to new replies.

Advertisement