diff --git a/build/modules/raylib.core b/build/modules/raylib.core index a65b858..e469394 100644 --- a/build/modules/raylib.core +++ b/build/modules/raylib.core @@ -525,16 +525,16 @@ EndVrStereoMode :: #foreign () // End stereo renderi // Shader management functions // NOTE: Shader functionality is not available on OpenGL 1.1 -// LoadShader :: #foreign (vsFileName: *char, fsFileName: *char): Shader // Load shader from files and bind default locations -// LoadShaderFromMemory :: #foreign (vsCode, fsCode: *char): Shader // Load shader from code strings and bind default locations -// IsShaderReady :: #foreign (shader: Shader): bool // Check if a shader is ready -// GetShaderLocation :: #foreign (shader: Shader, uniformName: *char): int // Get shader uniform location -// GetShaderLocationAttrib :: #foreign (shader: Shader, attribName: *char): int // Get shader attribute location -// SetShaderValue :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, value: *void, uniformType: ShaderUniformDataType) // Set shader uniform value -// SetShaderValueV :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, value: *void, uniformType: ShaderUniformDataType, count: int) // Set shader uniform value vector -// SetShaderValueMatrix :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, mat: Matrix) // Set shader uniform value (matrix 4x4) -// SetShaderValueTexture :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, texture: Texture2D) // Set shader uniform value for texture (sampler2d) -// UnloadShader :: #foreign (shader: Shader) // Unload shader from GPU memory (VRAM) +LoadShader :: #foreign (vsFileName: *char, fsFileName: *char): Shader // Load shader from files and bind default locations +LoadShaderFromMemory :: #foreign (vsCode: *char, fsCode: *char): Shader // Load shader from code strings and bind default locations +IsShaderReady :: #foreign (shader: Shader): bool // Check if a shader is ready +GetShaderLocation :: #foreign (shader: Shader, uniformName: *char): int // Get shader uniform location +GetShaderLocationAttrib :: #foreign (shader: Shader, attribName: *char): int // Get shader attribute location +SetShaderValue :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, value: *void, uniformType: ShaderUniformDataType) // Set shader uniform value +SetShaderValueV :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, value: *void, uniformType: ShaderUniformDataType, count: int) // Set shader uniform value vector +SetShaderValueMatrix :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, mat: Matrix) // Set shader uniform value (matrix 4x4) +SetShaderValueTexture :: #foreign (shader: Shader, locIndex: ShaderLocationIndex, texture: Texture2D) // Set shader uniform value for texture (sampler2d) +UnloadShader :: #foreign (shader: Shader) // Unload shader from GPU memory (VRAM) // Screen-space-related functions diff --git a/build/rtsgame/array.core b/build/rtsgame/array.core new file mode 100644 index 0000000..f181d30 --- /dev/null +++ b/build/rtsgame/array.core @@ -0,0 +1,15 @@ +#import "LibC.core" + +Array :: struct($T: Type) + data: *T + len: int + cap: int + +Add :: (a: *Array($T), item: T) + if a.cap == 0 + a.cap = 16 + a.data = malloc(SizeOf(T) * a.cap->U64) + if a.len + 1 > a.cap + a.cap *= 2 + a.data = realloc(a.data, SizeOf(T) * a.cap->U64) + a.data[a.len++] = item diff --git a/build/rtsgame/main.core b/build/rtsgame/main.core index a010d7b..810a582 100644 --- a/build/rtsgame/main.core +++ b/build/rtsgame/main.core @@ -1,6 +1,7 @@ -#import "LibC.core" #import "raylib.core" +#load "array.core" + /*@feature_idea: labeled block It acts just like a scope in C. @@ -42,54 +43,87 @@ Add :: (a: *Array($T), item: T) guys: Array(Guy) Add(&guys, {100, 100}) */ -Array :: struct($T: Type) - data: *T - len: int - cap: int + + +// @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}; + Guy :: struct pos: Vector2 -Add :: (a: *Array($T), item: T) - if a.cap == 0 - a.cap = 16 - a.data = malloc(SizeOf(T) * a.cap->U64) - if a.len + 1 > a.cap - a.cap *= 2 - a.data = realloc(a.data, SizeOf(T) * a.cap->U64) - a.data[a.len++] = item +Map_Tile :: int +Map :: struct + data: *Map_Tile + x: int + y: int +SCR_X := 1280 +SCR_Y := 720 + +M_X := 0 +M_Y := 0 +M_P: Vector2 main :: (): int guys: Array(Guy) Add(&guys, {pos = {100, 100}}) - InitWindow(1280, 720, "Testing") + + map_data: [16*16]int + map: Map = {data = &map_data[0], x = 16, y = 16} + + InitWindow(SCR_X, SCR_Y, "Testing") SetTargetFPS(60) + + // InitAudioDevice() + // sound := LoadSound("catune - Pass the town, and to the C.mp3") + // SetMasterVolume(0.01) + // PlaySound(sound) + + for !WindowShouldClose() - - Y := GetScreenHeight() - g := guys.data - if IsKeyDown(KEY_W);; g.pos.y -= 2 - if IsKeyDown(KEY_S);; g.pos.y += 2 - if IsKeyDown(KEY_A);; g.pos.x -= 2 - if IsKeyDown(KEY_D);; g.pos.x += 2 - + SCR_X = GetScreenWidth() + SCR_Y = GetScreenHeight() + M_X = GetMouseX() + M_Y = GetMouseY() + M_P = GetMousePosition() BeginDrawing() ClearBackground(RAYWHITE) - DrawFPS(0, 0) - DrawText(TextFormat("Testing %d", 32), 100, 100, 20, MAROON) - DrawCube({0,0,0}, 10, 10, 10, BLACK) - for i := 0, i < guys.len, i += 1 - it := guys.data + i - DrawCircleV(it.pos, 16, MAROON) + + RX := 16 + RY := 16 + for x := 0, x < 16, x += 1 + for y := 0, y < 16, y += 1 + it := map.data[x + y*map.x] + r: Rectangle = {(x * RX)->F32, (y * RY)->F32, RX->F32, RY->F32} + r2: Rectangle = {r.x + 1, r.y + 1, r.width - 2, r.height - 2} + + color := RED + if it == 1 ;; color = GREEN + if CheckCollisionPointRec(M_P, r) ;; color = BLUE + + DrawRectangleRec(r2, color) + + + // DrawFPS(0, 0) + // DrawText(TextFormat("Testing %d", 32), 100, 100, 20, MAROON) EndDrawing() return 0 - - - - - - diff --git a/core_compiler.cpp b/core_compiler.cpp index 9b95e1d..4587054 100644 --- a/core_compiler.cpp +++ b/core_compiler.cpp @@ -14,7 +14,7 @@ static void core_init_compiler(Core_Ctx *ctx, Allocator *allocator) { pctx = ctx; ctx->emit_type_info = true; - ctx->emit_line_directives = false; + ctx->emit_line_directives = true; ctx->debugger_break_on_compiler_error = true; ctx->same_scope_token = {SAME_SCOPE};