Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,388 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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