2024-09-04 22:43:27 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import rl "vendor:raylib"
|
2024-09-05 22:39:52 +03:00
|
|
|
import "core:slice"
|
2024-09-05 23:42:18 +03:00
|
|
|
import "core:fmt"
|
2024-09-04 22:43:27 +03:00
|
|
|
|
|
|
|
Vec2 :: [2]f32
|
|
|
|
Vec2i :: [2]i32
|
|
|
|
|
2024-09-05 23:42:18 +03:00
|
|
|
WINDOW : Vec2i
|
|
|
|
WINDOWF : Vec2
|
2024-09-05 22:39:52 +03:00
|
|
|
|
2024-09-04 22:43:27 +03:00
|
|
|
|
|
|
|
main :: proc() {
|
2024-09-05 23:42:18 +03:00
|
|
|
rl.SetConfigFlags(rl.ConfigFlags{.FULLSCREEN_MODE, .VSYNC_HINT, .WINDOW_MAXIMIZED, .WINDOW_UNDECORATED})
|
2024-09-05 22:39:52 +03:00
|
|
|
monitor := rl.GetCurrentMonitor()
|
2024-09-05 23:42:18 +03:00
|
|
|
rl.InitWindow(0, 0, "SinePong")
|
2024-09-05 22:39:52 +03:00
|
|
|
rl.SetTargetFPS(9999)
|
|
|
|
|
2024-09-05 23:42:18 +03:00
|
|
|
WINDOW.x = rl.GetScreenWidth()
|
|
|
|
WINDOW.y = rl.GetScreenHeight()
|
|
|
|
WINDOWF = Vec2{f32(WINDOW.x), f32(WINDOW.y)}
|
|
|
|
|
2024-09-05 22:39:52 +03:00
|
|
|
stack_init()
|
|
|
|
|
|
|
|
defer {
|
|
|
|
for s, i in state_stack {
|
|
|
|
free(s)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
game := game_init()
|
|
|
|
append(&state_stack, game)
|
|
|
|
|
|
|
|
for (!rl.WindowShouldClose()) {
|
|
|
|
if rl.IsWindowResized() {
|
2024-09-05 23:42:18 +03:00
|
|
|
WINDOW.x = rl.GetScreenWidth()
|
|
|
|
WINDOW.y = rl.GetScreenHeight()
|
|
|
|
WINDOWF = Vec2{f32(WINDOW.x), f32(WINDOW.y)}
|
2024-09-05 22:39:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
current_state := state_stack[len(state_stack)-1]
|
|
|
|
|
|
|
|
delta := rl.GetFrameTime()
|
|
|
|
|
|
|
|
current_state->update(delta)
|
|
|
|
|
|
|
|
{
|
|
|
|
rl.BeginDrawing()
|
|
|
|
defer rl.EndDrawing()
|
|
|
|
current_state->draw()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-09-04 22:43:27 +03:00
|
|
|
|
|
|
|
}
|