More raylib stuff, error messages matching sublime error format

This commit is contained in:
Krzosa Karol
2023-04-17 21:07:21 +02:00
parent 556677c42b
commit 7cb4b7145f
4 changed files with 254 additions and 24 deletions

View File

@@ -1,98 +0,0 @@
#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
TextFormat :: #foreign (str: *char, ...): *char
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