Skip to main content
GameDev.net gamedev.net
🔒 Locked

how to make a Real-Time Strategy Game(RTS) using OpenGL

Started by macmoy Dec 20, 2007 at 1:33 AM 19 replies 29.9k views
Original Post
macmoy
macmoy
First of all,,what are the RTS games that used OpenGL?? how to make one?? do you know "Battle for Mandicor"?? the graphics are poor but the gameplay is good.. i mean,the collision,ai,Fog of war,etc. ive already made tetris 3d..im planning to make a "Mario" game..but for me its... uhmmmm,,,,i dont know..maybe BORING.. im sorry,,im poor in english.. so by the way,,i want to make an RTS game with 2D graphics!!! so please,,Professional Programmers,Artists,Game Designers..kindly help me.. THANKS!!!!!!!
blueapple
blueapple
Quote:
so by the way,,i want to make an RTS game with 2D graphics!!!

Well....what are you waiting for then?

OpenGL is just a rendering engine, but if you've done a 3D Tetris using it already, you're probably familiar with it. (You'll need something to handle input etc, SDL for example.)

Quote:
First of all,,what are the RTS games that used OpenGL??

Just search google/wikipedia. Probably the big ones which are cross-platform.

Quote:
how to make one??

Well, you...you make one?

You will need something to hold your units. Make a unit class, and a game class which holds a list of all units. Then a rendering class (where you implement fog of war, sprite rendering, etc.). Then either put the logic in the game class or a separate class, then each update call getInput(), doLogic() and doRender(). And voila, StarCraft III is born.

But, honestly, your question is to wide to just give an answer to. Ask more specific things, like "I've implanted the A* path finding algorithm successfully, but the units sometimes go left instead of right. I believe the error is in this code sample." ~

"how do i make the great 2d rts?!! mario is to boring!" is not a good question.

Quote:
i mean,the collision,ai,Fog of war,etc.

As it's just 2D and an RTS, you'll probably get away with a simple "bounding box" check between the units. There's probably a tutorial/paper on how to implement Fog of war somewhere on the internet. Just search.

Quote:
ive already made tetris 3d..im planning to make a "Mario" game..but for me its...
uhmmmm,,,,i dont know..maybe BORING.. im sorry,,im poor in english..

I somehow think that you "copied" the "tetris 3d". Also, it might be boring when you start out. If it's your second game, don't aim too high. Go with something small, like a pong, simple space shooter (will learn you AI, collision detection, some scripting perhaps, 2D graphics etc.) etc.

Quote:
so by the way,,i want to make an RTS game with 2D graphics!!!

Sure. We all do.

Quote:
so please,,Professional Programmers,Artists,Game Designers..kindly help me..
THANKS!!!!!!!

Please ask more specific questions next time.
Check out my devlog.
macmoy
macmoy
hey thanks for your reply..

a*?? whats that??

question:
how to command the units to walk to a location and that/those units will avoid the rocks,trees,other units,etc.. i heard that's called "Avoidance"?? how is it done??


more simple games??? uhmm,, i dont know,,im too lazy to make games that doesn't enjoy me in the end.. like mario,,i really dont enjoy playing it.. sorry...

i really want to make RTS game..

im so sad that here in our country(philippines), we don't have teachers that teaches game programming..so im self-studying..

i really appreciate your reply guys...thanks!!!
Hnefi
Hnefi
Quote:
Original post by macmoy
hey thanks for your reply..

a*?? whats that??

A* is a pathfinding algorithm. It makes entities find their way to a certain goal.

Quote:
question:
how to command the units to walk to a location and that/those units will avoid the rocks,trees,other units,etc.. i heard that's called "Avoidance"?? how is it done??

Typically with a robust A* implementation.
Quote:
more simple games??? uhmm,, i dont know,,im too lazy to make games that doesn't enjoy me in the end.. like mario,,i really dont enjoy playing it.. sorry...

i really want to make RTS game..

Don't take this the wrong way, but if you're too lazy to make a simple game, what makes you think you have the energy to make a complex one? Games are tricky applications to make. They require a LOT of boring extra work. That work can easily become even more tedious if you don't have experience from simpler things, since you'll end up redoing everything three or five times to get it right.

So do as the person above advised, make simpler games first. Much of what you do to create a simple sidescroller can be used in an RTS anyway.

Quote:
im so sad that here in our country(philippines), we don't have teachers that teaches game programming..so im self-studying..

i really appreciate your reply guys...thanks!!!

Keep at it, and good luck.
-------------Please rate this post if it was useful.
macmoy
macmoy
aw..im sorry..i always push myself to create simpler games but when developing,,im losing my eagerness to make one..

why am i choosing to make RTS instead of simpler??

because i know in the end,,i can enjoy that game and its the start of making lots of RTS that can sharpen my skills..

what RTS game is made in opengl(C++)?? not BIG ones from example:blizzard,ubisoft..just the small ones..
blueapple
blueapple
Quote:
aw..im sorry..i always push myself to create simpler games but when developing,,im losing my eagerness to make one..
Quote:
Don't take this the wrong way, but if you're too lazy to make a simple game, what makes you think you have the energy to make a complex one? Games are tricky applications to make. They require a LOT of boring extra work. That work can easily become even more tedious if you don't have experience from simpler things, since you'll end up redoing everything three or five times to get it right.

--
Quote:
what RTS game is made in opengl(C++)?? not BIG ones from example:blizzard,ubisoft..just the small ones..
Why don't you search (and find out)?

Honestly, I don't think the graphics API used is what "makes a good RTS". Most of the big ones probably have both DirectX and OpenGL support implemented. If you want to look at sourcecode for how "the small ones" has coded their graphics class, you should probably start smaller.
Check out my devlog.
ff8
ff8
Quote:

..im planning to make a "Mario" game..but for me its...
uhmmmm,,,,i dont know..maybe BORING..


O_O;;

Mario isn't BORING..

take care..!

Ravuya
Ravuya
Moving to For Beginners.
Palidine
Palidine
Expectations:
1) An RTS game should take you around 1-2 years to make by yourself
2) You will not find tutorials for making an RTS game


Advice:
It doesn't matter what games are made with what. C++ and OpenGL is a fine combination to make an RTS game, that's all you need to know. Most AAA games are made with C++. Most big publishers use DirectX b/c they already are forced to use it for 360 development & they don't care about supporting Mac and Linux. If you know OpenGL stick with it; there's no need to learn DirectX for your purposes.

The basic components you'll need to build for your game (in a rough order in which you'll need them):

Core Engine (framework that ties everything together)
Graphics system
Networking (if you will support multiplayer)
Physics System
Game Logic (ruleset/units/weapons/etc for the game)
AI system
Audio System
Particle System (a nice to have, not necessary for functionality)

Each of these are pretty vast areas and will require months to develop and understand.

As for how to move units research "A* Pathfinding" "Basic Physics"

For how to collide units research: "collision detection"

Like I said, each of these topics will take months to understand, so you can't possibly get full answers in this thread.

Think of this thread as a "where do I start" not a "how do i make this game" and you'll get a lot more out of it.

-me
Vilem Otte
Vilem Otte
Well, you haven't to code whole game. If you wanna create games, buy (or get) a licenced copy of game engine, which will take care of this. I'm writing a game engine and it's not easy to implement pathfinding, AI, physics, ... (and if you wanna create good rts. you need it. Well the truth is, that I use experimental algorythms for almost everything, which were tested just in demos, no game engine or game).

Try web www.devmaster.net, there's database of engines.

Althrough if you wanna create your own game using just programming - one small advice, build editors, it'll really help with building a rts game.
Palidine
Palidine
Quote:
Original post by Vilem Otte
Well, you haven't to code whole game. If you wanna create games, buy (or get) a licenced copy of game engine, which will take care of this. I'm writing a game engine and it's not easy to implement pathfinding, AI, physics, ... (and if you wanna create good rts. you need it. Well the truth is, that I use experimental algorythms for almost everything, which were tested just in demos, no game engine or game).


Yes, definitely. Good point. If you don't care about making your own engine you can also buy a commercial RTS game: C&C: Tiberium Wars, Dawn of War, etc. Those games all come with built in Modding features. With that you can create your own units, art, ruleset without having to code anything (you'll need to script here and there but it's pretty easy)

-me
Drigovas
Drigovas
The openGL part of an RTS isn't even the difficult, or the interesting part of creating one. Actually, it's a tiny sliver of the code required [a tiny, TINY sliver. All the graphical code that goes into making a 2d rts game could likely fit in about 250 lines without too much trouble at all, <75 lines if you omit error correction and detection. It's a pretty tiny component].

But seriously, in the last few weeks you've come around wanting to make Counter-Strike, a worms-like game, mario, a racing game, and now an RTS [and I'd wager several others that I've simply not seen in the bit of time I view these forums]. All asking very introductory questions that show that no work on any of these projects has been actually done. Seriously, pick something, start it, put some effort into it, and either finish it or fail at it [either one really, as long as you give it a good try in the case of failure, will result in you learning substantial amounts]. It doesn't matter what it is. You do not possess the skills to bring your most extravagant dreams into reality just yet, and you never will unless you take the baby steps first. The people around here who are making games like pong and breakout aren't doing it because they seriously love pong and breakout, they are doing it because this gives them the foundation that they'll need to tackle something more substantial and more interesting.
macmoy
macmoy
i dont understand..

how to relate the grids into the character?? i mean,,

if it uses grid technique,,i can easily do it "IF" the characters interval for walking is the same as the cell width(the width of a box inside the grid)...
did you guys get me??sorry for poor english..

lets say the grid is 20 x 20..each cell is 64 x 64 px..so then character now is walking..and it is walking with an interval of 3px..so there will come a time that the chracter is occupying the space of 2 - 4 cells right?? did u get it??

how to use now the "box"collision detection.. i know, i know..but i really dont know how to...i know how to check collision for boxes..but with this kind of situation,,whats the process?? thanks guys!!
blueapple
blueapple
Quote:
Original post by macmoy
i dont understand..
Neither do we.
Quote:
Original post by macmoy
how to relate the grids into the character?? i mean,,

if it uses grid technique,,i can easily do it "IF" the characters interval for walking is the same as the cell width(the width of a box inside the grid)...
did you guys get me??sorry for poor english..

lets say the grid is 20 x 20..each cell is 64 x 64 px..so then character now is walking..and it is walking with an interval of 3px..so there will come a time that the chracter is occupying the space of 2 - 4 cells right?? did u get it??
Honestly, no.

But you could just make the tilemap contain stuff like grass and roads (Grounds), and everything that the units can collide with entities (rocks or w/e).
(Entity would be a class created by you, which contain x and y coordinates, perhaps x and y velocity (or an angle and velocity), sprite id, width and height etc.)
On a second thought, you could make the units inherit from the entity class. And then simply check collisions between entities.
Quote:
Original post by macmoy
how to use now the "box"collision detection.. i know, i know..but i really dont know how to...i know how to check collision for boxes..but with this kind of situation,,whats the process?? thanks guys!!
Google...Please?

There's even a little box at the top right of this page, just enter "bounding box collision detection".
And if you are trying to figure out pathfinding, search for "A* pathfinding tutorial".




You are probably trying to do something that's just too hard for you.
Just look in your other threads from this December:

CAR RACING GAME! need HELP!!
WORMS/GUNBOUND LAND help!
DOTA
HELP me on my thesis! please.. Counter-Strike
YES! i want to make a mario-like game,how?

You've been given dozen of tips in those threads.
You can't expect anyone of us to code a game for you and insert your name as the coder in the credits. But apparently, you do.

[Edited by - blueapple on December 21, 2007 10:56:41 AM]
Check out my devlog.
Drigovas
Drigovas
You're not going to have to count pixels. The logical representation of space within your game doesn't necessarily need to be the exact form in which you're going to be rendering it to screen, so pixels are meaningless [and frankly, it's obstructive to the process if you restrict yourself to pixel-related operations]. Instead you are likely going to be simple storing things on an integer-indexed grid, and maintaining things that exist on your grid [like players] as a grid coordinate followed by some sort of bias used for rendering. For example, the position of things would be logically important as the grid square on which they reside, a coordinate (x,y). When it comes time to render, you would add to that (x,y) some sort of floating point offset from the squares center, (dx, dy). You could then feed that augmented number into whatever you're using to render the square on the screen and actually render the thing at the spot ( x + dx, y + dy ).

Part of your animation will be augmenting that offset as things move around within the same tile [like walking across the tile], and when it reaches the edge of a tile, you'd change the tile (x,y) to be the new tile that the figure just moved onto, and augment the offset such that it references the spot that the figure just went to in the new tile.

But again, as usual, this is one of virtually uncountably many ways of solving this problem. The exact method you'd use depends on your exact objectives, and this method won't work great for every possible purpose. Take into consideration what you intend to do.
macmoy
macmoy
im so sorry.. still cant understand...

i used pixel just for example..

here is another example:(im using Opengl)

so every cell of the grid is measured 1.0f x 1.0f

//////

int grid[20][20];

//////

so that will give 20.0f x 20.0f dimension right?

now,,if,, i say,, "MArio" is walking..1st,,he is standing in the first cell
Location: grid[0][0] or lets say, (0.0f,0.0f) this is X and Y respectively..

so mario will walk by 0.2f..


now,,mario is at (0.2f,0.0f)..WHAT cell of the grid is he?? still at grid[0][0] or both grid[0][0] and grid[1][0] assuming that mario's width is the same as the width of every cell..so moving to the right by 0.2f will still occupy a space in grid[0][0] byt will also occupy a space in grid[1][0]..

did i make it clear??? im sorry if i cant explain my problem well...


thanks for any reply guys...
Zakwayda
Zakwayda
Quote:
Original post by macmoy
now,,mario is at (0.2f,0.0f)..WHAT cell of the grid is he?? still at grid[0][0] or both grid[0][0] and grid[1][0] assuming that mario's width is the same as the width of every cell..so moving to the right by 0.2f will still occupy a space in grid[0][0] byt will also occupy a space in grid[1][0]..
Sure - if both the cells and the player have dimensions of 1x1, and the player starts in cell 0,0 and moves .2 units along the horizontal axis, then the player will then partially occupy both cell (0,0) and cell (1,0), just as you said.

What this actually means, practically speaking, depends on gameplay mechanics and so forth (in other words, it's basically up to you how to handle it).
macmoy
macmoy
so if both cells is considered occupied?? how will i decide collision,,uhmm,, i cant express my prob..uhmm..let's say cel 0,0 and 1,0 is occupied..cell 3,0 is a wall..now what?

and my another problem is what if "mario" is jump? the collision of going up is different from going down.. of course,,the player can jump on a platform and land on an elevated platform.. thanks for replies...
macmoy
macmoy
please reply guys! thanks!
Crypter
Crypter
Hello,

Quote:

so if both cells is considered occupied?? how will i decide collision,,uhmm,, i cant express my prob..uhmm..let's say cel 0,0 and 1,0 is occupied..cell 3,0 is a wall..now what?


Give each tile different properties. If a tile is "solid", then a sprite cannot go through it, so perform collision test. If not, do not perform collision test.

Compare the bounding rectangle for both the tile and the sprite to see if they intersect to test collision. This should only be needed if the tile mario is touching is marked as "solid".

This is one way of doing this.

Quote:

and my another problem is what if "mario" is jump? the collision of going up is different from going down.. of course,,the player can jump on a platform and land on an elevated platform.. thanks for replies...

If you are using a bounding rectangle for collision detection, the collision detection will be the same.

All you need to do is determine if the tile mario is going on is solid or not. If it is, test collision with it. If not, dont do anything.

There are alot of ways this can be done...

*edit: There was a very good site that contained a 2d jump and run tutorial. It uses DirectDraw though (deprecated-should not use). I think the site is down now though..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.