Okay, most of you have played an RTS before. You click and drag and you form a little box on the screen to select a unit or a group of units. It's called lassoing units. Now I have figured out how to lasso units by dragging the mouse fine, it took about a day because it was somewhat complicated, but now it works perfectly, I can select units by dragging the mouse to lasso them. But there is one small detail remaining
I can't seem to figure out how I would go about drawing the box on the screen. I know this would prolly be easier if I'd upgrade to A6 and used draw_line or whatever that function is, but I don't know if I have the money. What I have done is create an onscreen entity that, when I drag, its scale_x and scale_y is modified. The problem with this is, 1, when I drag, the thickness of the lines distort, much like scaling a hollow cube in WED, and 2, I can't seem to get it so that one corner starts at the initial mouse click (mouseCoord1) and the diagnal corner at the final mouse release (mouseCoord2). The following code is my attempt at creating this box.
Code:
entity lassoBox
{
type = <lasso.bmp>;
layer = 2;
view = camera;
x = 100;
y = 0;
z = 0;
flags = visible;
}
function deselect() //deselects units and lassoes units
{
var recorded;
if(!key_ctrl) //if ctrl is not pressed
{
unselect = 1; //set unselect flag to unselect everything
wait(1); //wait a frame
unselect = 0; //re-enable selection
}
while(mouse_left) //while mouseLeft is pressed
{
if(recorded != 1) //if first position if mouse is not recorded
{
mouse_trace();
vec_set(mouseCoord1,target);
recorded = 1;
}
mouse_trace();
vec_set(mouseCoord2,target);
mouseCoord3.x = mouseCoord1.x; //find the next corner (don't need the fourth)
mouseCoord3.y = mouseCoord2.y;
mouseCoord3.z = 0;
lassoBox.scale_x = -vec_dist(mouseCoord2,mouseCoord3) / 100;
lassoBox.scale_y = -vec_dist(mouseCoord1,mouseCoord3) / 100;
wait(1);
}
mouse_trace();
vec_set(mouseCoord2,target);
lasso = 1;
wait(1);
lasso = 0;
recorded = 0;
return; //exit function
}
The entity, by the way is a 30x30 bitmap of a white square.