InitWindow := fn(w: uint, h: uint, name: ^u8): uint @import()
WindowShouldClose := fn(): bool @import()
BeginDrawing := fn(): void @import()
EndDrawing := fn(): void @import()
DrawRectangleV := fn(pos: Vec2, size: Vec2, color: Color): void @import()
DrawRectangle := fn(a: uint, b: uint, c: uint, d: uint, color: Color): void @import()
ClearBackground := fn(color: Color): void @import()
SetTargetFPS := fn(target: uint): void @import()
GetFrameTime := fn(): f32 @import()

Vec2 := struct {x: f32, y: f32}
Color := struct {r: u8, g: u8, b: u8, a: u8}

$W := 800
$H := 600

main := fn(): uint {
	_ = InitWindow(W, H, "whawee\0".ptr)

	SetTargetFPS(60)

	pos := Vec2.(100, 100)
	vel := Vec2.(300, 300)
	size := Vec2.(100, 100)
	color := Color.(17, 255, 17, 255)

	loop if WindowShouldClose() break else {
		BeginDrawing()
		ClearBackground(.(0, 0, 0, 255))

		DrawRectangleV(pos, size, color)
		pos += vel * .(GetFrameTime(), GetFrameTime())

		if pos.x < 0 | pos.x + size.x > W {
			vel.x *= -1
			color += .(32, 11, 20, 0)
		}

		if pos.y < 0 | pos.y + size.y > H {
			vel.y *= -1
			color += .(32, 11, 20, 0)
		}
		EndDrawing()
	}

	return 0
}