diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-08 19:49:47 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-08 19:49:47 -0400 |
| commit | a7ae25ec086117e133b2dfbbc1c5025aa2f29964 (patch) | |
| tree | 45bcab3728e0998205e280a0dd84a44bcb2925be /examples/game/game.tm | |
| parent | f86cc6549ff6075c3963fce819391d8d8d6960dc (diff) | |
Add example game using raylib
Diffstat (limited to 'examples/game/game.tm')
| -rw-r--r-- | examples/game/game.tm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/game/game.tm b/examples/game/game.tm new file mode 100644 index 00000000..368d17af --- /dev/null +++ b/examples/game/game.tm @@ -0,0 +1,42 @@ +# This game demo uses Raylib to present a simple +use libraylib.so +use <raylib.h> +use <raymath.h> +use file + +use ./world.tm + +func main(): + extern InitWindow:func(w:Int32, h:Int32, title:CString)->Void + InitWindow(1600, 900, "raylib [core] example - 2d camera") + + map := when read("map.txt") is Success(m): m + else: exit(code=1, "Could not find the game map!") + + World.CURRENT:load_map(map) + + extern SetTargetFPS:func(fps:Int32) + SetTargetFPS(60) + + extern WindowShouldClose:func()->Bool + + while not WindowShouldClose(): + extern GetFrameTime:func()->Num32 + dt := GetFrameTime() + World.CURRENT:update(Num(dt)) + + extern BeginDrawing:func() + BeginDrawing() + + inline C { + ClearBackground((Color){0xCC, 0xCC, 0xCC, 0xFF}); + } + + World.CURRENT:draw() + + extern EndDrawing:func() + EndDrawing() + + extern CloseWindow:func() + CloseWindow() + |
