I don't know if there is another term for it, but I mean this: You hold down a mouse button. A rectangle forms when you move the mouse around. The units inside the box get selected when you let go of the mouse button. I need this for a RTS style game I'm working on, but I don't know how to approach it.
I currently have functionality for selecting a unit, basically if you click within a certain area the unit is added to the list of selected units,
def mouseUp(self, button, pos): adjusted = self.coord_convert(pos) if button==1: for a in self.agent_list: if a.pos.get_distance(self.coord_convert_adjusted(pos)) < 16: self.selected.append(a) elif a in self.selected and a.pos.get_distance(self.coord_convert_adjusted(pos)) > 16: self.selected.remove(a)
The next step would be to allow for selecting multiple units at once by checking if they are inside a box, can you provide some guidance on how I should proceed?
Edit: To clarify, I'm asking how to create a box which starts at the position of MOUSEDOWN, and changes in size relative to mouse movement while holding the pressed button down, until let go.