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.
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.
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.