Core: Polymorphism works better then expected hmm...
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/*@language_refactor: Remove tuples and simplify, Make var unpacking general*/
|
||||
|
||||
/*@language_todo: make polymorphism checking more robust*/
|
||||
|
||||
/*@language_todo: labeled block
|
||||
@@ -25,7 +23,7 @@ thing := 1
|
||||
*/
|
||||
|
||||
#import "raylib.core"
|
||||
#load "array.core"
|
||||
A :: #load "array.core"
|
||||
MAP :: #load "map.core"
|
||||
sqrtf :: #foreign (value: F32): F32
|
||||
|
||||
@@ -47,12 +45,12 @@ Mode := 0
|
||||
RectX :: 16
|
||||
RectY :: 16
|
||||
Dt: F32
|
||||
ANI_SetTiles: Array(ANI_SetTile)
|
||||
ANI_SetTiles: A.Array(ANI_SetTile)
|
||||
|
||||
MouseSelecting := false
|
||||
MouseSelectionPivot: Vector2
|
||||
MouseSelectionBox: Rectangle
|
||||
MouseSelectedActors: Array(*MAP.Actor) // @todo: ids
|
||||
MouseSelectedActors: A.Array(*MAP.Actor) // @todo: ids
|
||||
|
||||
main :: (): int
|
||||
MAP.Init()
|
||||
@@ -88,7 +86,6 @@ main :: (): int
|
||||
MouseP = GetMousePosition()
|
||||
Dt = GetFrameTime()
|
||||
map := &MAP.CurrentMap
|
||||
ai := GetIndex(&map.actors, map.actors.data)
|
||||
|
||||
MouseSelecting = false
|
||||
if IsMouseButtonDown(MOUSE_BUTTON_LEFT)
|
||||
@@ -144,9 +141,9 @@ main :: (): int
|
||||
|
||||
if Mode == 0
|
||||
if colliding && IsMouseButtonDown(MOUSE_BUTTON_LEFT)
|
||||
Add(&ANI_SetTiles, {true, {x,y}})
|
||||
A.Add(&ANI_SetTiles, {true, {x,y}})
|
||||
if colliding && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)
|
||||
Add(&ANI_SetTiles, {false, {x,y}})
|
||||
A.Add(&ANI_SetTiles, {false, {x,y}})
|
||||
if colliding == true ;; color = {a = 100}
|
||||
|
||||
DrawRectangleRec(r2, color)
|
||||
@@ -181,7 +178,7 @@ main :: (): int
|
||||
|
||||
tile_it.t += Dt*8
|
||||
if remove
|
||||
UnorderedRemove(&ANI_SetTiles, tile_it)
|
||||
A.UnorderedRemove(&ANI_SetTiles, tile_it)
|
||||
tile_i -= 1
|
||||
|
||||
for i := 0, i < map.actors.len, i += 1
|
||||
@@ -232,7 +229,7 @@ main :: (): int
|
||||
MAP.SetTargetP(actor_it, p)
|
||||
|
||||
if MouseSelecting
|
||||
Reset(&MouseSelectedActors)
|
||||
A.Reset(&MouseSelectedActors)
|
||||
COLOR_SelectionBox := GREEN
|
||||
COLOR_SelectionBox.a = 255/2
|
||||
|
||||
@@ -241,7 +238,7 @@ main :: (): int
|
||||
actor_box := MAP.Rect(actor_it.p)
|
||||
|
||||
if CheckCollisionRecs(actor_box, MouseSelectionBox)
|
||||
Add(&MouseSelectedActors, actor_it)
|
||||
A.Add(&MouseSelectedActors, actor_it)
|
||||
|
||||
DrawRectangleRec(MouseSelectionBox, COLOR_SelectionBox)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user