RTS engine: simple example?

Started by
3 comments, last by XTF 12 years, 7 months ago
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.
Advertisement
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).

http://www.mediafire...2cvyc4r1n3qh84u

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:

http://en.wikipedia....ric_Free_Engine

http://en.wikipedia....8game_engine%29

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).
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.

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.

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.
Nobody else?
Is there a better place for such questions?

This topic is closed to new replies.

Advertisement