Sign in to follow this  
XTF

RTS engine: simple example?

Recommended Posts

I'm interested in writing a Command & Conquer clone in C++. Are there any simple RTS engines that I could have a look at for ideas and examples? I'm mostly interested in the game model, how do units move, attack, etc.

Share this post


Link to post
Share on other sites
Well, it's in Python and it's very messy, but I've uploaded a project I did a while ago, trying to replicate the basic mechanics of an RTS (I was going for an Age of Empires clone feel).

[url="http://www.mediafire.com/?2cvyc4r1n3qh84u"]http://www.mediafire...2cvyc4r1n3qh84u[/url]

In it, units attack, move, gather resources and build structures, though there are no animations and there isn't much GUI feedback, so it can be hard to tell if anything's happening. Note that there is no pathing in this example, which is a very important part of unit movement in RTS games. Most of the stuff you expressed an interest in is in the Units.py file. Best get a proper Python IDE for this; reading it in a word processor is even worse.

To sum up: I had the units have a task list, with each task having a name ("attack" or "move" or whatever), and coordinates, speed values, or a target of some sort. The unit would in its portion of the game cycle, execute whatever task was on its list at that time. The code might be too messy to be of any help; if you want, you can PM me to ask about details, and I'll try to help you as best I can, but I abandoned this project several months ago to move onto other things (though I have done some A* pathfinding in the meantime).

There are two seemingly well-developped engines out there that could be used for RTS games that you could also check out:

[url="http://en.wikipedia.org/wiki/Flexible_Isometric_Free_Engine"]http://en.wikipedia....ric_Free_Engine[/url]

[url="http://en.wikipedia.org/wiki/Spring_%28game_engine%29"]http://en.wikipedia....8game_engine%29[/url]

Best of luck! People say RTS games are very hard, but I've worked on a lot of the systems involved, and they're actually not that hard to wrap your head around (except AI - I haven't even gone near that yet, and I think that's the hardest part of all). Besides AI, the hardest is probably pathfinding - which, admittedly, I've not yet experimented with using large numbers of units (at most, I've tested situations with about 30 entities pathfinding at the same time - peanuts compared to a game like Age of Empires 2).

Share this post


Link to post
Share on other sites
Units selection / command handling is pretty straightforward, you can implement it the way you want. What's harder is the pathfinding, and especially flocking when multiple units move the same path if you don't want them to stack up.

Share this post


Link to post
Share on other sites
[quote name='Saldan' timestamp='1313695879' post='4850891']
In it, units attack, move, gather resources and build structures, though there are no animations and there isn't much GUI feedback, so it can be hard to tell if anything's happening.[/quote]
Does your example contain any kind of (unpassable) terrain or collision detection? Units appear to move in a straight line to their destination.

I can do pathing, but movement is a bit more complicated. I'm using a rectangular grid. I think it's easiest if units are restricted to moving from center of cell to center of cell. Now I'm wondering how to do movement while taking acceleration into account. Avoiding in-place turning would also be nice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this