96 lines
1.6 KiB
Core
96 lines
1.6 KiB
Core
#import "LibC.core"
|
|
#import "raylib.core"
|
|
|
|
/*@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})
|
|
*/
|
|
Array :: struct($T: Type)
|
|
data: *T
|
|
len: int
|
|
cap: int
|
|
|
|
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
|
|
|
|
|
|
main :: (): int
|
|
guys: Array(Guy)
|
|
Add(&guys, {pos = {100, 100}})
|
|
|
|
InitWindow(1280, 720, "Testing")
|
|
SetTargetFPS(60)
|
|
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
|
|
|
|
|
|
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)
|
|
EndDrawing()
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|