diff options
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r-- | examples/games/raylib_emscripten.zc | 32 |
2 files changed, 37 insertions, 0 deletions
@@ -338,6 +338,8 @@ impl Point { #### Traits Define shared behavior. ```zc +struct Circle { radius: f32; } + trait Drawable { fn draw(self); } @@ -345,6 +347,9 @@ trait Drawable { impl Drawable for Circle { fn draw(self) { ... } } + +var circle = Circle{}; +var drawable: Drawable = &circle; ``` #### Composition diff --git a/examples/games/raylib_emscripten.zc b/examples/games/raylib_emscripten.zc new file mode 100644 index 0000000..bbdf907 --- /dev/null +++ b/examples/games/raylib_emscripten.zc @@ -0,0 +1,32 @@ +// This example demonstrates a minimal raylib example that is compilable with Emscripten. + +// Pre-requisites: +// Setup emscripten from here: https://emscripten.org/docs/getting_started/downloads.html +// Compile raylib for web following this guide: https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5) + +// Build instructions: +// zc build raylib_emscripten.zc --cc emcc -o game.html + +// NOTE: Modify these lines as you see fit, pointing to where your web build of raylib is installed +//> include: ./raylib/include +//> libs: ./raylib +//> link: ./raylib/libraylib.a + +// DO NOT modify this line +//> link: -s ASYNCIFY -s ASSERTIONS -s USE_GLFW=3 -s WASM=1 -s GL_ENABLE_GET_PROC_ADDRESS=1 + +import "raylib.h" + +fn main() { + InitWindow(1280, 720, "Hello Zen-C"); + defer CloseWindow(); + + while (!WindowShouldClose()) { + BeginDrawing(); + defer EndDrawing(); + + ClearBackground(BLACK); + + DrawText("Hello Zen-C", 10, 10, 20, WHITE); + } +} |
