Selection and setting target_p
This commit is contained in:
@@ -102,6 +102,7 @@ ANI_SetTiles: Array(ANI_SetTile)
|
||||
MouseSelecting := false
|
||||
MouseSelectionPivot: Vector2
|
||||
MouseSelectionBox: Rectangle
|
||||
MouseSelectedActors: Array(*MAP_Actor) // @todo: ids
|
||||
|
||||
main :: (): int
|
||||
MAP_Init()
|
||||
@@ -150,6 +151,13 @@ main :: (): int
|
||||
MouseP.y - MouseSelectionPivot.y
|
||||
}
|
||||
|
||||
if MouseSelectionBox.width < 0
|
||||
MouseSelectionBox.x += MouseSelectionBox.width
|
||||
MouseSelectionBox.width = -MouseSelectionBox.width
|
||||
if MouseSelectionBox.height < 0
|
||||
MouseSelectionBox.y += MouseSelectionBox.height
|
||||
MouseSelectionBox.height = -MouseSelectionBox.height
|
||||
|
||||
if IsKeyPressed(KEY_F1)
|
||||
Mode = 0
|
||||
|
||||
@@ -270,10 +278,30 @@ main :: (): int
|
||||
DrawCircleV(p0, 4, LIGHTGRAY)
|
||||
DrawCircleV(p1, 4, LIGHTGRAY)
|
||||
|
||||
if Mode == 1 && MouseSelecting
|
||||
COLOR_SelectionBox := GREEN
|
||||
COLOR_SelectionBox.a = 255/2
|
||||
DrawRectangleRec(MouseSelectionBox, COLOR_SelectionBox)
|
||||
if Mode == 1
|
||||
for actor_i := 0, actor_i < MouseSelectedActors.len, actor_i += 1
|
||||
actor_it := MouseSelectedActors.data[actor_i]
|
||||
actor_box := MAP_Rectangle(actor_it.p)
|
||||
DrawRectangleRec(actor_box, GREEN)
|
||||
|
||||
if IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)
|
||||
p := MAP_ScreenToMap(MouseP)
|
||||
MAP_SetTargetP(actor_it, p)
|
||||
|
||||
if MouseSelecting
|
||||
Reset(&MouseSelectedActors)
|
||||
COLOR_SelectionBox := GREEN
|
||||
COLOR_SelectionBox.a = 255/2
|
||||
|
||||
for actor_i := 0, actor_i < map.actors.len, actor_i += 1
|
||||
actor_it := map.actors.data + actor_i
|
||||
actor_box := MAP_Rectangle(actor_it.p)
|
||||
|
||||
if CheckCollisionRecs(actor_box, MouseSelectionBox)
|
||||
Add(&MouseSelectedActors, actor_it)
|
||||
|
||||
DrawRectangleRec(MouseSelectionBox, COLOR_SelectionBox)
|
||||
|
||||
|
||||
menu_open := false
|
||||
if menu_open
|
||||
|
||||
Reference in New Issue
Block a user