Gamestudio Links
Zorro Links
Newest Posts
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
FXCM => AVA Trade Plugin???
by Martin_HH. 11/17/26 17:02
contractUpdate() is filtering if >2 rows
by mistery. 11/09/26 12:06
New Zorro version 3.15
by jcl. 11/09/26 09:24
Removing outliers from files
by jcl. 11/04/26 10:30
[MED] Import from FBX (2010) missing!!!
by rayp. 11/03/26 14:33
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (LucasJoshua, Quad, 1 invisible), 37,619 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
RTS Box Selection #160950
10/14/07 15:09
10/14/07 15:09
Joined: Apr 2007
Posts: 67
suriname0 Offline OP
Junior Member
suriname0  Offline OP
Junior Member

Joined: Apr 2007
Posts: 67
I have been working on a simplistic RTS, but I have been having trouble with Box Selection. (Drag to select multiple units.) I wrote this code:

Code:

if (mouse_left == on) && (mouse_moving)
{
boxX=mouse_pos.x;
boxY=mouse_pos.y;
mouse_map = Mouse_Box;

while(mouse_left == on)
{
draw_line(vector(BoxX, BoxY, 0), NULL, 90);
draw_line(vector(BoxX, mouse_pos.Y, 0), vector(140,131,131), 90);
draw_line(vector(mouse_pos.x, mouse_pos.y, 0), vector(140,131,131), 90);
draw_line(vector(mouse_pos.x, BoxY, 0), vector(140,131,131), 90);
draw_line(vector(BoxX, BoxY, 0), vector(140,131,131), 90);
wait(1);
}
}


It works fine, and the box looks good, but I don't know how to select the units inside of it. Does anyone know how to do this? (I thought about using C_scan, or creating a block to go collide with my units, but really i'm stumped...)


If I am posting, it probably means I am asking a question. Or faking my knowledge by agreeing with somebody else.
Re: RTS Box Selection [Re: suriname0] #160951
10/14/07 15:58
10/14/07 15:58
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
Use vec_to_screen to get a units XY screen coordinates..then check these XY if they are within the drag box boundaries


I like good 'views' because they have no 'strings' attached..
Re: RTS Box Selection [Re: zazang] #160952
10/24/07 00:17
10/24/07 00:17
Joined: Apr 2007
Posts: 67
suriname0 Offline OP
Junior Member
suriname0  Offline OP
Junior Member

Joined: Apr 2007
Posts: 67
Thanks, but I still went wrong somewhere. It thinks my unit is always outside of the "view" parameter. (I call it like this:
Code:

temp=me;
if (vec_to_screen(temp,camera) == 1)
{
//An annoyingly large # of "if" statements
}
else
{
beep();
}


)
So what does that mean? Is there soem other view I should use? or is there some obscure camera var not mentioned in my manual???

Thanks for the help...


If I am posting, it probably means I am asking a question. Or faking my knowledge by agreeing with somebody else.

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1