Compiling with MSVC, Using raylib! Cleanup

This commit is contained in:
Krzosa Karol
2023-04-05 21:49:05 +02:00
parent d7c96b0ebc
commit fb9c8728ea
14 changed files with 8864 additions and 143 deletions

View File

@@ -0,0 +1,93 @@
#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: S64
cap: S64
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()
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({100})
DrawText("Testing and stuff", 100, 100, 20, RAYWHITE)
for i := 0, i < guys.len, i += 1
it := guys.data + i
DrawCircleV(it.pos, 16, MAROON)
EndDrawing()
return 0

View File

@@ -1,16 +1,5 @@
/*
PushStruct :: (a: *MA.Arena, $T: Type): *$T
size := size_of(Type)
result := PushSize(a, size)
return result
Array(int)
QueueAddSLL(list: $List, node: $Node, first: #Identifier = first, last: #Identifier = last, next: #Identifier = next)
ArrayAdd(array: $Array, item: $Item, data: #Identifier = data, len: #Identifier = len, len: #Identifier = cap)
/* @todo
QueueAddSLL(list: $List, node: $Node, $first = first, $last = last, $next = next)
if list.first == 0
list.first = list.last = node
@@ -100,8 +89,7 @@ main :: (argc: int, argv: **char): int
Add(&third_array, 32)
Add(&fourth, 32)
Add(&fifth, 32)
Add(&sixth, {32})
// Add(&seventh, {32, 32, 32})
// Add(&sixth, {32}) // @todo this is possible !
// value := PolyLambda(**int)
// PolyType_r1 := PolyType(10)