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.

DarkBASIC Discussion / RTS unit selection

Author
Message
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 19th Feb 2007 01:04 Edited at: 19th Feb 2007 05:34
I am working on an RTS game and am trying to fine tune my unit selection function. It currently works so that if you sorround the units in a square and the center of the object is in the square they become selected, but I would also like the player to be able to click a unit to select it. Does anyone have an idea on how this might be done?

Thanks
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Feb 2007 04:04
Since DBC doesn't have a pick object command, simplist way would be to just check a certain radius of the unit's screen coordinates and see if the mouse is within that range.



luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 19th Feb 2007 05:34
Thanks Phaelax. I guess I was looking for something more accurate but it works out good. I set it so if the area of the selection square the player draws is very small it just checks for a unit that is within a certain distance of the mouse position like you suggested.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Feb 2007 12:08
How big are the objects you want to click on? Tiny, small, medium or large?

I only ask because I worked on this a long time ago and from what I remember I had limited success with it - what you wanted to click on couldn't be too small.

I'll see if I can find the code - if I can...

TDK_Man

luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 19th Feb 2007 22:15 Edited at: 19th Feb 2007 22:19
I dont have the actual models yet but the placeholders are spheres with a diameter of 50

here is a screenshot of them in the game

Attachments

Login to view attachments
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 22nd Feb 2007 05:45 Edited at: 22nd Feb 2007 05:47
Another Question:

Im trying to set up my program so the units arrange themselves in a box but I think I may be doing something wrong. Can anyone take a look at this and tell me why it doesn't work?



The function that controls the formations is under Get_Destination() but I included more so you can see how the unit formations work now.

EDIT:

the program requires no outside media so you can just copy the code into DB but uses the enhancement pack

Login to post a reply

Server time is: 2025-05-26 02:57:03
Your offset time is: 2025-05-26 02:57:03