add web build

This commit is contained in:
2026-11-03 14:19:16 +03:00
parent 6003acd40c
commit f6efe2956e
3 changed files with 139 additions and 17 deletions

View File

@@ -1,7 +1,11 @@
(include raylib.h)
(define WIN-WIDTH 1440)
(define WIN-HEIGHT 900)
#-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
@@ -9,19 +13,47 @@
(if (! (,test))
(do
(TraceLog LOG-ERROR ,msg)
(return ,code)))))
(= error ,code)
(return)))))
(pub fn main ((argc int) (argv [* const char])) int
(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)
(while (! (WindowShouldClose))
(BeginDrawing)
(ClearBackground BLACK)
(DrawCircle (/ WIN-WIDTH 2) (/ WIN-HEIGHT 2) 100.0f RAYWHITE)
(EndDrawing))
(SetTargetFPS 60))
(fn deinit () void
(CloseAudioDevice)
(CloseWindow)
(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))