Start rts thing
This commit is contained in:
@@ -525,16 +525,16 @@ EndVrStereoMode :: #foreign () // End stereo renderi
|
|||||||
// Shader management functions
|
// Shader management functions
|
||||||
// NOTE: Shader functionality is not available on OpenGL 1.1
|
// 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
|
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
|
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
|
IsShaderReady :: #foreign (shader: Shader): bool // Check if a shader is ready
|
||||||
// GetShaderLocation :: #foreign (shader: Shader, uniformName: *char): int // Get shader uniform location
|
GetShaderLocation :: #foreign (shader: Shader, uniformName: *char): int // Get shader uniform location
|
||||||
// GetShaderLocationAttrib :: #foreign (shader: Shader, attribName: *char): int // Get shader attribute 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
|
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
|
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)
|
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)
|
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)
|
UnloadShader :: #foreign (shader: Shader) // Unload shader from GPU memory (VRAM)
|
||||||
|
|
||||||
// Screen-space-related functions
|
// Screen-space-related functions
|
||||||
|
|
||||||
|
|||||||
15
build/rtsgame/array.core
Normal file
15
build/rtsgame/array.core
Normal file
@@ -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
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#import "LibC.core"
|
|
||||||
#import "raylib.core"
|
#import "raylib.core"
|
||||||
|
|
||||||
|
#load "array.core"
|
||||||
|
|
||||||
/*@feature_idea: labeled block
|
/*@feature_idea: labeled block
|
||||||
|
|
||||||
It acts just like a scope in C.
|
It acts just like a scope in C.
|
||||||
@@ -42,54 +43,87 @@ Add :: (a: *Array($T), item: T)
|
|||||||
guys: Array(Guy)
|
guys: Array(Guy)
|
||||||
Add(&guys, {100, 100})
|
Add(&guys, {100, 100})
|
||||||
*/
|
*/
|
||||||
Array :: struct($T: Type)
|
|
||||||
data: *T
|
|
||||||
len: int
|
// @reproduction
|
||||||
cap: int
|
// 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
|
Guy :: struct
|
||||||
pos: Vector2
|
pos: Vector2
|
||||||
|
|
||||||
Add :: (a: *Array($T), item: T)
|
Map_Tile :: int
|
||||||
if a.cap == 0
|
Map :: struct
|
||||||
a.cap = 16
|
data: *Map_Tile
|
||||||
a.data = malloc(SizeOf(T) * a.cap->U64)
|
x: int
|
||||||
if a.len + 1 > a.cap
|
y: int
|
||||||
a.cap *= 2
|
|
||||||
a.data = realloc(a.data, SizeOf(T) * a.cap->U64)
|
|
||||||
a.data[a.len++] = item
|
|
||||||
|
|
||||||
|
SCR_X := 1280
|
||||||
|
SCR_Y := 720
|
||||||
|
|
||||||
|
M_X := 0
|
||||||
|
M_Y := 0
|
||||||
|
M_P: Vector2
|
||||||
|
|
||||||
main :: (): int
|
main :: (): int
|
||||||
guys: Array(Guy)
|
guys: Array(Guy)
|
||||||
Add(&guys, {pos = {100, 100}})
|
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)
|
SetTargetFPS(60)
|
||||||
|
|
||||||
|
// InitAudioDevice()
|
||||||
|
// sound := LoadSound("catune - Pass the town, and to the C.mp3")
|
||||||
|
// SetMasterVolume(0.01)
|
||||||
|
// PlaySound(sound)
|
||||||
|
|
||||||
|
|
||||||
for !WindowShouldClose()
|
for !WindowShouldClose()
|
||||||
|
SCR_X = GetScreenWidth()
|
||||||
Y := GetScreenHeight()
|
SCR_Y = GetScreenHeight()
|
||||||
g := guys.data
|
M_X = GetMouseX()
|
||||||
if IsKeyDown(KEY_W);; g.pos.y -= 2
|
M_Y = GetMouseY()
|
||||||
if IsKeyDown(KEY_S);; g.pos.y += 2
|
M_P = GetMousePosition()
|
||||||
if IsKeyDown(KEY_A);; g.pos.x -= 2
|
|
||||||
if IsKeyDown(KEY_D);; g.pos.x += 2
|
|
||||||
|
|
||||||
|
|
||||||
BeginDrawing()
|
BeginDrawing()
|
||||||
ClearBackground(RAYWHITE)
|
ClearBackground(RAYWHITE)
|
||||||
DrawFPS(0, 0)
|
|
||||||
DrawText(TextFormat("Testing %d", 32), 100, 100, 20, MAROON)
|
RX := 16
|
||||||
DrawCube({0,0,0}, 10, 10, 10, BLACK)
|
RY := 16
|
||||||
for i := 0, i < guys.len, i += 1
|
for x := 0, x < 16, x += 1
|
||||||
it := guys.data + i
|
for y := 0, y < 16, y += 1
|
||||||
DrawCircleV(it.pos, 16, MAROON)
|
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()
|
EndDrawing()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ static void core_init_compiler(Core_Ctx *ctx, Allocator *allocator) {
|
|||||||
pctx = ctx;
|
pctx = ctx;
|
||||||
|
|
||||||
ctx->emit_type_info = true;
|
ctx->emit_type_info = true;
|
||||||
ctx->emit_line_directives = false;
|
ctx->emit_line_directives = true;
|
||||||
ctx->debugger_break_on_compiler_error = true;
|
ctx->debugger_break_on_compiler_error = true;
|
||||||
ctx->same_scope_token = {SAME_SCOPE};
|
ctx->same_scope_token = {SAME_SCOPE};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user