Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [STICKY] The RTS is back!

Author
Message
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 14th Dec 2004 03:12 Edited at: 24th Oct 2016 13:02
I got bored yesterday and decided to write an RTS tutorial. It's not finished by my standards, but at already 12pages long it should be enough to get anyone started. Topics covered so far is 3d mouse clicking, unit selection, unit grouping, unit management, resource gathering, beginning map design for future concepts. Check the download button for the zip file containing the RTF document.

News: 2005-09-13
New link added to the online tutorial. It's where I will be making my updates from now on. The web-based tutorial is currently in the staged of chapter 12, which can be partially seen online now.

Update: 2006-05-21

DBP 5.8
Web-based tutorial (currently offline)
- A* pathfinding (IanM's library)
- Assign group numbers (ctrl + 1-9), select groups (1-9)
- Group formations, (press spacekey to assign block formation)
- Harvest resources (select unit, right click tree)

DBC 1.13
- older version for DB classic, not much included
- Assign and select groups via numbers

Oct 24, 2016
Tutorial can now be found here:
http://dbcc.zimnox.com/?page=tutorials


RTS Resources
open source rts engines/games
ORTS
Spring
Stratagus
Glest

Fog of War Tutorial (C++)

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
Osiris
12
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 14th Dec 2004 06:50
very nice!

BaZko
12
Years of Service
User Offline
Joined: 24th Sep 2004
Location:
Posted: 14th Dec 2004 08:04 Edited at: 14th Dec 2004 08:05
Can this work for dbc?
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 15th Dec 2004 01:16
If you change some things. The only real DBP dependent features used were array lists and UDTs.

"eureka" - Archimedes
Philip
14
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 15th Dec 2004 06:27
I think Phaelax is the only person I know who gets "bored" and then produces something akin to a work of art that obviously took intense thought and care.

I admire that.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 15th Dec 2004 09:34
Look at the avatar, apears to be intensly thinking about something.

Very nice work there!

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
Mattman
14
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 15th Dec 2004 09:57
It will mostly work if you use DarkEDIT as it supports UDT's, just a different style

Song of the whenever i feel like updating it....
Whatever Happened, The Strokes
Ian T
14
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 15th Dec 2004 10:17
Nicely done indeed

sadsack
13
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 16th Dec 2004 09:01
very nice, I going try to make since out of your great code. I will be able to use that code with my civil war game. thank you
renny
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 16th Dec 2004 09:42
added a new section on animation. shows how to setup code so that your characters animation stages change appropriately, and with very little code.

"eureka" - Archimedes
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 17th Dec 2004 04:05
Click the download button in the first post to get the updated document. I copied the wrong source code, so you'll have to do without that for now. It's all pretty much in the document anyway.

"eureka" - Archimedes
Spline
12
Years of Service
User Offline
Joined: 30th Oct 2004
Location: London U.K
Posted: 17th Dec 2004 06:49
nice work Phaelax, it all seams a bit complicated i might understand one day, thanks
Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 17th Dec 2004 12:09
That is very nice work! Great job Phaelax!

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
David R
13
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 17th Dec 2004 20:59
Great - but this puzzled me:

Selecting units does still work corerctly on a matrix which is not flat. I am making a game at the moment, and it works perfectly - and very accurate too. Why does it not work according to your doc?

<html>
<img src="http://www.freewebs.com/lightningstudios/lightningstudios_logo.jpg" border=0 />
</html>
French gui
13
Years of Service
User Offline
Joined: 11th May 2004
Location: France
Posted: 17th Dec 2004 23:53
You've made a great work on this Phaelax!!! It's very interresting and so useful. Oh yes, do some tutorials on pathfinding please! How the dwarf will reach his destination point, avoiding houses and trees on his path?

My English is not so good I'm just French
genius
13
Years of Service
User Offline
Joined: 16th Oct 2003
Location: Utah, USA
Posted: 18th Dec 2004 00:55
IanM did a nice A* pathfinding routine
http://forum.thegamecreators.com/?m=forum_view&t=11137&b=6

Why do they have BRAIL on Drive-Up ATM Machines?
http://www.tamperstudios.com
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 18th Dec 2004 14:13
Quote: "Selecting units does still work corerctly on a matrix which is not flat. I am making a game at the moment, and it works perfectly - and very accurate too. Why does it not work according to your doc?"


It's not the unit selecting, its the targeting position; when you right-click. To translate the 2d mouse into 3d coordinates, you'll need a different function for random terrain than the one I used.

Most likely, I will be using IanM's library in the example when I get to it. I used it in older versions and it works very well.

"eureka" - Archimedes
aks74u
13
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 24th Dec 2004 14:55
nice great job

Over And Out.
The Goldorak
12
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 3rd Jan 2005 02:03
Great job Phaelax !

Why do you not use this code to build a real rts game ?


Darkbasic is great !
Neofish
13
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 3rd Jan 2005 12:29 Edited at: 3rd Jan 2005 23:44
Seeming as I want to make an RTS this is of great interest to me (it will afferm and correct stuff for me )

Thanks (i'll comment on it when I've read it )

EDIT: Just had a quick look at it, looks very good expecially animating which I have only theorised about.

EDIT AGAIN: Just read first 5 sections, it's very good, although I would have ordered it differently. I'm sure this will be of great use

aks74u
13
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 4th Jan 2005 11:01
we want sum mo' we want sum mo'

Over And Out.
Neofish
13
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 4th Jan 2005 12:30
Indeed we do

I've got up to section 6 and this is what I have: http://pulse.dbspot.com/downloads/RTS.rar

Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 4th Jan 2005 13:01 Edited at: 4th Jan 2005 13:05
To keep you camera above the terrain, try this:

+ Code Snippet

p.s. Not actual code, just example. And if I get some free time here soon, I'll make a good RTS camera on a terrain as demostrated above one post.

Looking good!

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
Neofish
13
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 4th Jan 2005 14:53 Edited at: 4th Jan 2005 14:54
@Gen, was that to me because my camera does stay above the terrain (except maybe) when it starts, the camera is slightly offset then) or for who?

Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 4th Jan 2005 22:38 Edited at: 4th Jan 2005 22:39
Yes it went under the terrain a few timesbut seemed to work at the other end of the terrain.

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
Neofish
13
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 5th Jan 2005 03:33
Currently the camera is forced 5 units above the terrain, might change that to 10 to higher, but it shouldn't go under the terrain at all

Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 5th Jan 2005 05:06
WELL IT DID!

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
Maleck
13
Years of Service
User Offline
Joined: 12th May 2004
Location: US
Posted: 5th Jan 2005 07:24
Great job Phaelax, I am looking forward to going through this very soon.
Neofish
13
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 6th Jan 2005 05:22
Quote: "WELL IT DID!"

*Hides in fear*

Could you tell me at which point/s on the map it went through?

Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 6th Jan 2005 07:46
I think I made a mistake. I just took another look and I think it was the end of the terrain. When it first loads up, I went forward, then backward but went to far back and was off the terrain. It looks somewhat like you go off the map though.

But the camera still is not being forced 5 units above the terrain. Im always way above the terrain. about the highest peak on the terrain is where the cam tends to stay.

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
Neofish
13
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 7th Jan 2005 02:31
Odd...the 5 units is a minimum, it's now something like 15 and I changed the way the camera works (it still sucks) but now it's more RTS like , if I get animation done today (got to do preparation for my art exam for tomorrow) I'll upload and show my amazingness



LeaderOne
13
Years of Service
User Offline
Joined: 9th Jan 2004
Location:
Posted: 8th Jan 2005 11:04
That tutorial is very flavoursome. Classic.

You said to suggest things, so here goes:

a) fog of war
b) multiplayer support
c) A.I.
d) shots per sec, i.e. the ballista on AoE shot once/3 secs, but in DBPro the sync rate changes. (Hope you got that)
e) formations. In that download you gave me in August, if you selected all units and moved to the center, all that happened is that the group moved to the center, relative to the center of the group. Solution: AoK style formations
f) can we have different terrains? i.e. grass, desert, water etc?

sorry if that was a bit much

"Chicken is nice"
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 8th Jan 2005 17:16
I definately have formations planned out, real formations. Not like I had in my old versions. Terrain is your job, its not RTS related. Shots per second is no problem, and it's really not any different than the tree chopping. I'm still working on fog of war. It kinda works, but I'm not happy with it yet. Multiplayer support near the end of the project. AI, well hmm... We'll see. I'd like too, but well, ya know how it is.

"eureka" - Archimedes
Neofish
13
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 8th Jan 2005 23:25
Quote: "shots per sec, i.e. the ballista on AoE shot once/3 secs, but in DBPro the sync rate changes."

Delta Time could/should help there

Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 9th Jan 2005 11:37
Yes, you can set some sort of time to control the speed of the game. I remember seeing how to do it once in C++, but unfortunaly, I dont remember how.

But also, instead of once every 3 seconds, you also do it once every 150 fps.

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 9th Jan 2005 16:06
once every 150 frames is a bad idea. Some computers would shoot faster than others. The characters chop wood at 1unit per second. its not hard

"eureka" - Archimedes
Mattman
14
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 13th Jan 2005 07:57 Edited at: 13th Jan 2005 08:07
And then their respective models could go with that....

couldn't they?

Also, another topic:

Researching. I could do this but some newbies might find it helpful and would be fairly simple to add.

Hi
LeaderOne
13
Years of Service
User Offline
Joined: 9th Jan 2004
Location:
Posted: 13th Jan 2005 09:38
Yes.

AI though is tough. In DR the computer cuts the board up, and sent the according amount of his units to your units... If you know what I mean.

Anyway, I mentioned Terrain 'cause of having a set out height, rather that a flat matrix.

Good Job on it Phaelax! (that is so hard to spell! )

"Chicken is nice"
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 13th Jan 2005 20:54
Research as in learn new skills as you build up? That's simple enough. Just build a tree of all your technologies.
I've got a major study going on that I've started with OpenGL this week, but I'm going to try and update the tutorial with formations tonight.
I'm thinking about doing some real basic AI. If any of you have played WC3, you know those misc creatures that roam around the forests? They don't build bases or anything, just attack you if you get too near.

"eureka" - Archimedes
Mattman
14
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 13th Jan 2005 21:42
Love WC3. Maybe I'll add research if youre busy? I need to do something for the community

Hi
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 17th Jan 2005 22:09
I'm working on "Step 10: Formations" right now, but I have to get to class real soon, So I'll have to finish it later. I also thought of another section to add, in-game interface. This additional mini tutorial would cover the aspects of a mini-map, and providing the link between player and character interaction.(such as assigning formations to a group, or sending a peasant to chop wood)

"eureka" - Archimedes
fasdfsdaf
12
Years of Service
User Offline
Joined: 17th Jan 2005
Location:
Posted: 22nd Jan 2005 05:34
Is there a way to change this into "total war" with resources gained each turn and a campaign map?

www.war3forums.net
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 28th Jan 2005 16:06
What's total war?

I've updated the code finally. This section is on adding character formations. It shows how to set up the code so that it may be expanded to support an unlimited number of different formations, and how to keep your units in formation when moving to new target destinations. I kinda rushed through it, so lemme know if you find any errors.

+ Code Snippet

"eureka" - Archimedes

Attachments

Login to view attachments
TEH_CODERER
13
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 29th Jan 2005 18:21
WHAT IS TOTAL WAR???!!!
WHAT IS TOTAL WAR???!!!
Only the best RTS known to man!!!

Gil Galvanti
12
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 30th Jan 2005 00:42
suggestions:
1)not having to drag to select a unit
2)AI
3)building things

Video games…they can take you places unreachable, impossible, unfeasible. They put you in the book...they put you in the movie...they put you in a world, a world that before could only be imagined.
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 30th Jan 2005 05:00
I'm getting there. And what you mean not having to drag to select units? How else are you suppose to get your troops?

And no, age of empires 2 is the best rts! (or the first red alert)

"eureka" - Archimedes
Gen
13
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 30th Jan 2005 13:19
Quote: "1)not having to drag to select a unit"


He means to click a unit to select it without having the selection box.

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.
Mattman
14
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 30th Jan 2005 13:21
left click the unit

Something to doing?
Phaelax
DBPro Master
14
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Agartha
Posted: 30th Jan 2005 15:09
oh that. thats easy, i just haven't felt like talking about it yet. There's still things in my old rts that I haven't covered in the new one yet, like pathfinding and fow.

"eureka" - Archimedes
TEH_CODERER
13
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 31st Jan 2005 02:57
Yeah. I was exaggerating.
My personal favourite is actually Dungeon Keeper 2.

Login to post a reply

Server time is: 2017-07-22 03:53:47
Your offset time is: 2017-07-22 03:53:47