/*@feature_idea: labeled block It acts just like a scope in C. BUT it can be turned into a goto label by adding another semicolon at the end. :block thing := 1 thing2 := thing :label_without_block thing := 1 :goto_block: thing := 1 thing2 := thing :goto_block: for */ /* @reproduction: This kills the compiler due to referencing slice data Array :: struct($T: Type) slice: []T cap: S64 Guy :: struct pos: Vector2 Add :: (a: *Array($T), item: T) if a.cap == 0 a.cap = 16 a.slice.data = malloc(SizeOf(T) * a.cap) a.slice.data[a.slice.len++] = item guys: Array(Guy) Add(&guys, {100, 100}) */ // @reproduction // MAP: [16*16]int = {0, 1} // // This generates: int MAP[256] = (int [256]){[0] = 0, [0] = 1}; it doesn't work because of the (int[256]) is this MSVC being retarded here? not supporting C properly? // Also this ^ ^ // @reproduction // map_data: [16*16]int // map: Map = {data = map_data->*int, 16, 16} // // Failed to cast from [[256]int] to [*int] // @reproduction // map_data: [16*16]int // map: Map = {data = &map_data[0], 16, 16} // // Map map = (Map ){.data = (&(map_data[0])), .data = 0x10, .x = 16}; // @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" #load "map.core" V2I :: struct x: int y: int WinX := 1280 WinY := 720 MouseX := 0 MouseY := 0 MouseP: Vector2 Mode := 0 RectX :: 16 RectY :: 16 main :: (): int MAP_Init() // InitAudioDevice() // sound := LoadSound("catune - Pass the town, and to the C.mp3") // SetMasterVolume(0.01) // PlaySound(sound) InitWindow(WinX, WinY, "Testing") SetTargetFPS(60) for !WindowShouldClose() WinX = GetScreenWidth() WinY = GetScreenHeight() MouseX = GetMouseX() MouseY = GetMouseY() MouseP = GetMousePosition() map := &MAP_CurrentMap if IsKeyPressed(KEY_F1) ;; Mode = 0 if IsKeyPressed(KEY_F2) ;; Mode = 1 if IsKeyPressed(KEY_F3) for i := 0, i < map.actors.len, i += 1 it := map.actors.data + i MAP_MoveTowardsTarget(it) if IsKeyDown(KEY_SPACE) for i := 0, i < map.actors.len, i += 1 it := map.actors.data + i MAP_PathFindStep(it) BeginDrawing() ClearBackground(RAYWHITE) 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} 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 if colliding == true ;; color = MAROON DrawRectangleRec(r2, color) for i := 0, i < map.actors.len, i += 1 actor_it := map.actors.data + i r := Rectangle{actor_it.p.x->F32 * RectX, actor_it.p.y->F32 * RectY, RectX, RectY} target_r := Rectangle{actor_it.target_p.x->F32 * RectX, actor_it.target_p.y->F32 * RectY, RectX, RectY} DrawRectangleRec(r, YELLOW) DrawRectangleRec(target_r, PURPLE) for path_i := 0, path_i < actor_it.open_paths.len, path_i += 1 path_it := actor_it.open_paths.data + path_i path_r := Rectangle{path_it.p.x->F32 * RectX, path_it.p.y->F32 * RectY, RectX, RectY} DrawRectangleRec(path_r, ORANGE) for path_i := 0, path_i < actor_it.close_paths.len, path_i += 1 path_it := actor_it.close_paths.data + path_i path_r := Rectangle{path_it.p.x->F32 * RectX, path_it.p.y->F32 * RectY, RectX, RectY} DrawRectangleRec(path_r, BROWN) MAP_RecomputeHistory(actor_it) for path_i := 0, path_i < actor_it.history.len, path_i += 1 path_it := actor_it.history.data + path_i path_r := Rectangle{path_it.p.x->F32 * RectX, path_it.p.y->F32 * RectY, RectX, RectY} DrawRectangleRec(path_r, BLACK) if Mode == 0 ;; DrawText("F1", 0, 0, 32, BLACK) if Mode == 1 ;; DrawText("F2", 0, 0, 32, BLACK) EndDrawing() return 0