aboutsummaryrefslogtreecommitdiff
path: root/examples/game/game.tm
blob: c7d843e3a82fe2aaa08eb899acec74a3f3ec3e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# This game demo uses Raylib to present a simple 
use libraylib.so
use <raylib.h>
use <raymath.h>

use ./world.tm

func main(map=(./map.txt)):
    extern InitWindow:func(w:Int32, h:Int32, title:CString)->Void
    InitWindow(1600, 900, "raylib [core] example - 2d camera")

    map_contents := map:read() or exit("Could not find the game map: $map")

    World.CURRENT:load_map(map_contents)

    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()