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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
selection box #289504
09/13/09 16:43
09/13/09 16:43
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
i am currently making an rts game, but when i added a selection box for selecting troops, there became massive fps lag.
So basically i am asking for some code to create a click-and- drag box, because i must be doing something wrong.

Thanks


One day there will be an unfixable bug,
That day is not today.
Re: selection box [Re: dakilla] #289508
09/13/09 17:03
09/13/09 17:03
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
The selection box can be drawn using draw_line, draw_quad or something similar.

To check if any entity is within the box, you could cycle through all visible entities (with ent_next() + CLIPPED flag or ent_pvs()) and convert their world coordinates to screen coordinates (vec_to_screen()). Each entities screen coords have to be compared with the screen coords of the selection box.

Re: selection box [Re: Saturnus] #289509
09/13/09 17:11
09/13/09 17:11
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
thanks, but i have made the code already, its just it impacts loads on the fps, so i was looking for ways to avoid this


One day there will be an unfixable bug,
That day is not today.
Re: selection box [Re: dakilla] #291607
09/26/09 17:44
09/26/09 17:44
Joined: Sep 2009
Posts: 12
Z
zero_karma Offline
Newbie
zero_karma  Offline
Newbie
Z

Joined: Sep 2009
Posts: 12
Maybe if there is no way to avoid it you should just use the code that calculates the vectors to draw the borders of the box then NOT draw the borders; you could point and drag and the troops that WOULD be inside the box are selected as you drag the "would-be" box over them. I've seen this in pro games before so it isn't that bad of a work around.


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