Core: Fix couldnt infer compound expression

This commit is contained in:
Krzosa Karol
2023-04-21 08:39:33 +02:00
parent ada87e6adf
commit 3207a390c8
2 changed files with 8 additions and 12 deletions

View File

@@ -66,10 +66,6 @@ Add(&guys, {100, 100})
// Error! Couldn't infer type of compound expression
// if Mode == 1 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) ;; MAP.CurrentMAP.actors.data[0].p = {x,y}
// @compiler_todo: It's possible to have 2 definitions with same name. 1 global, 1 local
// Mode := 0
// main :: ()
// if IsKeyPressed(KEY_F1) ;; Mode := 0
#import "raylib.core"
#load "array.core"
@@ -102,6 +98,7 @@ MouseSelectionPivot: Vector2
MouseSelectionBox: Rectangle
MouseSelectedActors: Array(*MAP.Actor) // @todo: ids
main :: (): int
MAP.Init()
@@ -129,7 +126,6 @@ main :: (): int
target_color.a = 255/2
for !WindowShouldClose()
WinX = GetScreenWidth()
WinY = GetScreenHeight()
MouseX = GetMouseX()
@@ -143,7 +139,7 @@ main :: (): int
MouseSelecting = true
if IsMouseButtonPressed(MOUSE_BUTTON_LEFT)
MouseSelectionPivot = MouseP
MouseSelectionBox = Rectangle{
MouseSelectionBox = {
MouseSelectionPivot.x,
MouseSelectionPivot.y,
MouseP.x - MouseSelectionPivot.x,
@@ -176,14 +172,14 @@ main :: (): int
BeginDrawing()
ClearBackground(RAYWHITE)
map_rectangle: Rectangle = {0, 0, map.x->F32 * RectX, map.y->F32 * RectY}
map_rectangle := Rectangle{0, 0, map.x->F32 * RectX, map.y->F32 * RectY}
DrawRectangleRec(map_rectangle, LIGHTGRAY)
for x := 0, x < map.x, x += 1
for y := 0, y < map.y, y += 1
it := map.data + (x + y*map.x)
r: Rectangle = {x->F32 * RectX, y->F32 * RectY, RectX, RectY}
r2: Rectangle = {r.x + 1, r.y + 1, r.width - 2, r.height - 2}
r := Rectangle{x->F32 * RectX, y->F32 * RectY, RectX, RectY}
r2 := Rectangle{r.x + 1, r.y + 1, r.width - 2, r.height - 2}
colliding := CheckCollisionPointRec(MouseP, r)
color := RAYWHITE
@@ -195,7 +191,7 @@ main :: (): int
Add(&ANI_SetTiles, {true, {x,y}})
if colliding && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)
Add(&ANI_SetTiles, {false, {x,y}})
if colliding == true ;; color = Color{a = 100}
if colliding == true ;; color = {a = 100}
DrawRectangleRec(r2, color)
@@ -217,7 +213,7 @@ main :: (): int
wd := w - wt
hd := h - ht
r: Rectangle = {x + wd/2, y + hd/2, wt, ht}
r := Rectangle{x + wd/2, y + hd/2, wt, ht}
DrawRectangleRec(r, GRAY)