Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,365 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 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 | chip programmers | 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