Advertisement Jump to content
Sign in to follow this  

RTS Map Mechanics

This topic is 2838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody, I just had a few quick questions, but nothing too specific.

Previously, I have coded a simple galaga-like game and a more in depth platformer. Now I am starting to make an RTS style game as my new project, but the structuring of an RTS already seems to be pretty different than things I have made in the past.

My basic game will be a 2D RTS, with the camera looking down on the battle field from above. You are able to place structure, and structures are the primary defense. You can also produce units, which can be used to attack enemy towers. Really the game is like a mix of an RTS and a versus tower defense game.

I just had a few quick questions about the basic setup for coding (from an object-oriented language).

Right now I have a World class, and the world contains a 2-Dimensional array of shorts that I am using to store the elevation of the terrain at the point represented by the x and y coordinates. Simple enough so far. With my World class, I do not really see what I should do to make units interact correctly with the terrain. I realized I will eventually need to work on path-finding, but I will learn that more when I get to that point.
1.) What method would the community suggest for placing unit objects on the map, and having them be aware of the terrain ?
2.) How would I most efficiently have units check for other units? I think that calling some method in the World would get cumbersome with all of that method overhead.
3.) Any other tips from people that have made the game?

Thank you in advance.

Share this post

Link to post
Share on other sites
Shameless bump (since I basically changed the whole question (since nobody was answering before)).

Also, mods, would this topic be better suited for the Game Programming forum? I would make one their but after reading the newcomer rule pinned on here I would rather not. It discouraged "cross topics" or something like that.

Share this post

Link to post
Share on other sites
Well for my rts game I have a terrain class that I made static so I could in my object base class do something like this
Bool unit::addtoterrain()
Cell *cell = terrain:: getcell(unitpos);
The do what ever you need to do

It my not be the best way but it looks like it works

Share this post

Link to post
Share on other sites
Hmmm, making my World class static could also work I suppose. It isn't like I am going to need more than one of those too terribly often.

So in your case, I assume Cell is another class used to represent a spot on the Terrain? My only concern with that is it would cause a lot of allocation. See, I am making this for Android and iOS (primarily Android), and allocation of object and the ensuing garbage collection are things that I have been looking to avoid.

Ok so what if I did this. I made my World class static and put in a "load" method, or something to that effect. I could pass it the resource ID for the raw file I am using to describe the terrain, and then read that into my 2D array. Would it be awful if a made my array public? I realize that it is not proper encapsulation, but sacrifices must be made on occasion.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!