Files
catch-phase/main.sex
2026-11-03 19:35:11 +03:00

60 lines
1.4 KiB
Scheme

(include raylib.h)
#-emscripten (define WIN-WIDTH 1440)
#-emscripten (define WIN-HEIGHT 900)
#+emscripten (define WIN-WIDTH 960)
#+emscripten (define WIN-HEIGHT 600)
(var error i32 0)
(defmacro (call-and-check test msg code fn . args)
`(do
(,fn ,@args)
(if (! (,test))
(do
(TraceLog LOG-ERROR ,msg)
(= error ,code)
(return)))))
(fn update () void
(BeginDrawing)
(ClearBackground BLACK)
(DrawTriangleGradient
#(Vector2 : (- (/ WIN-WIDTH 2) 100) (+ (/ WIN-HEIGHT 2) 100.0f))
#(Vector2 : (+ (/ WIN-WIDTH 2) 100) (+ (/ WIN-HEIGHT 2) 100.0f))
#(Vector2 : (/ WIN-WIDTH 2) (- (/ WIN-HEIGHT 2) 100))
RED
GREEN
BLUE)
(EndDrawing))
(fn init () void
(TraceLog LOG-INFO "hello from Catch-Phase! initializing resources...")
(call-and-check IsWindowReady "failed to create window" 1
InitWindow WIN-WIDTH WIN-HEIGHT "Catch-Phase")
(call-and-check IsAudioDeviceReady "failed to init audio" 2
InitAudioDevice)
(SetTargetFPS 60))
(fn deinit () void
(CloseAudioDevice)
(CloseWindow))
#-emscripten
(pub fn main ((argc int) (argv [* const char])) int
(init)
(if (!= error 0)
(return error))
(while (! (WindowShouldClose))
(update))
(return 0))
#+emscripten
(include emscripten.h)
#+emscripten
(pub fn main ((argc int) (argv [* const char])) int
(init)
(emscripten-set-main-loop update 0 true)
(return 0))