RTS, Fix invalid struct names in type info
This commit is contained in:
@@ -4,6 +4,7 @@ malloc :: #foreign (size: size_t): *void
|
||||
realloc :: #foreign (ptr: *void, size: size_t): *void
|
||||
free :: #foreign (ptr: *void)
|
||||
|
||||
memset :: #foreign (ptr: *void, val: int, num: size_t): *void
|
||||
memcpy :: #foreign (dst: *void, src: *void, size: size_t): *void
|
||||
memmove :: #foreign (dst: *void, src: *void, size: size_t): *void
|
||||
|
||||
|
||||
@@ -60,15 +60,18 @@ Add(&guys, {100, 100})
|
||||
//
|
||||
// Map map = (Map ){.data = (&(map_data[0])), .data = 0x10, .x = 16};
|
||||
|
||||
// @reproduction
|
||||
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = {x,y}
|
||||
//
|
||||
// Error! Couldn't infer type of compound expression
|
||||
//
|
||||
// Couldn't figure out type of compound expression when variable got declared and separetly
|
||||
// @reproduction Couldn't figure out type of compound expression when variable got declared and separetly
|
||||
// got assigned a value
|
||||
//
|
||||
// Error! Couldn't infer type of compound expression
|
||||
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = {x,y}
|
||||
// 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"
|
||||
@@ -108,15 +111,16 @@ main :: (): int
|
||||
MouseY = GetMouseY()
|
||||
MouseP = GetMousePosition()
|
||||
|
||||
if IsKeyPressed(KEY_F1) ;; Mode := 0
|
||||
if IsKeyPressed(KEY_F2) ;; Mode := 1
|
||||
if IsKeyPressed(KEY_F1) ;; Mode = 0
|
||||
if IsKeyPressed(KEY_F2) ;; Mode = 1
|
||||
if IsKeyPressed(KEY_F3)
|
||||
MAP_Reset()
|
||||
if IsKeyDown(KEY_SPACE)
|
||||
MAP_PathFindStep()
|
||||
|
||||
BeginDrawing()
|
||||
ClearBackground(RAYWHITE)
|
||||
|
||||
|
||||
map := &MAP_CurrentMap
|
||||
for x := 0, x < map.x, x += 1
|
||||
for y := 0, y < map.y, y += 1
|
||||
@@ -127,6 +131,8 @@ main :: (): int
|
||||
colliding := CheckCollisionPointRec(MouseP, r)
|
||||
|
||||
if Mode == 0 && colliding && IsMouseButtonDown(MOUSE_BUTTON_LEFT) ;; *it = 1
|
||||
if Mode == 1 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) ;; MAP_CurrentMap.actors.data[0].p = V2I{x,y}
|
||||
if Mode == 1 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; MAP_CurrentMap.actors.data[0].target_p = V2I{x,y}
|
||||
|
||||
color := GREEN
|
||||
if *it == 1 ;; color = RED
|
||||
@@ -152,7 +158,10 @@ main :: (): int
|
||||
it := MAP_History.data + i
|
||||
r := Rectangle{it.p.x->F32 * RectX, it.p.y->F32 * RectY, RectX, RectY}
|
||||
DrawRectangleRec(r, BLACK)
|
||||
DrawText("Reached target !", 0, 0, 32, BLACK)
|
||||
|
||||
if Mode == 0 ;; DrawText("F1", 0, 0, 32, BLACK)
|
||||
if Mode == 1 ;; DrawText("F2", 0, 0, 32, BLACK)
|
||||
|
||||
|
||||
EndDrawing()
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
MAP_CurrentMap: MAP_Map
|
||||
MAP_OpenPaths: Array(MAP_Path)
|
||||
MAP_ClosePaths: Array(MAP_Path)
|
||||
@@ -23,11 +22,25 @@ MAP_Path :: struct
|
||||
p: V2I
|
||||
came_from: V2I
|
||||
|
||||
MAP_Reset :: ()
|
||||
bytes := SizeOf(MAP_Tile) * MAP_CurrentMap.x->U64 * MAP_CurrentMap.y->U64
|
||||
|
||||
Reset(&MAP_CurrentMap.actors)
|
||||
Reset(&MAP_OpenPaths)
|
||||
Reset(&MAP_ClosePaths)
|
||||
Reset(&MAP_History)
|
||||
MAP_ReachedTarget = false
|
||||
|
||||
memset(MAP_CurrentMap.data, 0, bytes)
|
||||
Add(&MAP_CurrentMap.actors, {{4, 4}, {8, 8}})
|
||||
MAP_PathFindStart(MAP_CurrentMap.actors.data + 0)
|
||||
|
||||
MAP_Init :: ()
|
||||
MAP_CurrentMap.x = 60
|
||||
MAP_CurrentMap.y = 40
|
||||
MAP_CurrentMap.data = malloc(SizeOf(MAP_Tile) * MAP_CurrentMap.x->U64 * MAP_CurrentMap.y->U64)
|
||||
Add(&MAP_CurrentMap.actors, {{4, 4}, {8, 8}})
|
||||
bytes := SizeOf(MAP_Tile) * MAP_CurrentMap.x->U64 * MAP_CurrentMap.y->U64
|
||||
MAP_CurrentMap.data = malloc(bytes)
|
||||
MAP_Reset()
|
||||
|
||||
MAP_InsertOpenPath :: (p: V2I, target_p: V2I, came_from: V2I)
|
||||
if p.x < 0 || p.x >= MAP_CurrentMap.x ;; return
|
||||
|
||||
Reference in New Issue
Block a user