Files
corelang/build/rtsgame/main.core

147 lines
3.3 KiB
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})
*/
// @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};
// @reproduction
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = {x,y}
//
// Error! Couldn't infer type of compound expression
//
// Couldn't figure out type of compound expression when variable got declared and separetly
// got assigned a value
//
#import "raylib.core"
#load "array.core"
#load "map.core"
V2I :: struct
x: int
y: int
WinX := 1280
WinY := 720
MouseX := 0
MouseY := 0
MouseP: Vector2
Mode := 0
RectX :: 16
RectY :: 16
main :: (): int
MAP_Init()
// InitAudioDevice()
// sound := LoadSound("catune - Pass the town, and to the C.mp3")
// SetMasterVolume(0.01)
// PlaySound(sound)
InitWindow(WinX, WinY, "Testing")
SetTargetFPS(60)
for !WindowShouldClose()
WinX = GetScreenWidth()
WinY = GetScreenHeight()
MouseX = GetMouseX()
MouseY = GetMouseY()
MouseP = GetMousePosition()
if IsKeyPressed(KEY_F1) ;; Mode := 0
if IsKeyPressed(KEY_F2) ;; Mode := 1
BeginDrawing()
ClearBackground(RAYWHITE)
map := &MAP_CurrentMap
for x := 0, x < map.x, x += 1
for y := 0, y < map.y, y += 1
it := map.data + (x + y*map.x)
r: Rectangle = {x->F32 * RectX, y->F32 * RectY, RectX, RectY}
r2: Rectangle = {r.x + 1, r.y + 1, r.width - 2, r.height - 2}
colliding := CheckCollisionPointRec(MouseP, r)
if Mode == 0 && colliding && IsMouseButtonDown(MOUSE_BUTTON_LEFT) ;; *it = 1
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = V2I{x,y}
color := GREEN
if *it == 1 ;; color = RED
if colliding == true ;; color = MAROON
DrawRectangleRec(r2, color)
for i := 0, i < map.actors.len, i += 1
it := map.actors.data + i
r := Rectangle{it.p.x->F32 * RectX, it.p.y->F32 * RectY, RectX, RectY}
target_r := Rectangle{it.target_p.x->F32 * RectX, it.target_p.y->F32 * RectY, RectX, RectY}
DrawRectangleRec(r, YELLOW)
DrawRectangleRec(target_r, PURPLE)
// DrawFPS(0, 0)
// DrawText(TextFormat("Testing %d", 32), 100, 100, 20, MAROON)
EndDrawing()
return 0