Re: XNA Game Studio Express Grouping units like in a RTS game
Calvin Bell
Here is an idea for you. Since I haven't actually done it yet, I'm not sure if this is the best way to go about this.
Take the point where the user clicked and started dragging, and draw a
line that starts at the click point and goes on the Y to wherever the
mouse currently is (keep x at 0). Draw another line that does the
same but reversed (draw on X, keep y at 0). Also, draw a line
from the current mouse position up to the x that you started at and on
the y to where you started at. That will give you a rectangle on
your screen that will move when you move the mouse. When you
detect that the mouse button has been lifted, change those 4 lines into
a box(rectangle ), and loop through every unit on your screen to see if
its in that box. I hope thats close because I wouldn't want to
mislead someone.