aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
blob: f24057bea27f7bad810ada2429c829a74b537558 (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
const game = @import("game.zig");
const std = @import("std");
const utils = @import("utils.zig");
const w4 = @import("wasm4.zig");

//----- Globals ---------------------------------------------------------------
var Game: game.Game = undefined;
var wait_before_new_round: u8 = 0;

export fn start() void {
    Game.reset();
}

export fn update() void {
    if (wait_before_new_round == 0) {
        const finished = Game.update();
        if (finished) {
            wait_before_new_round = 60;
        }
    } else {
        wait_before_new_round -= 1;
        if (wait_before_new_round == 0) {
            Game.resetRound();
        }
    }
    Game.draw();
}