aboutsummaryrefslogtreecommitdiff
path: root/projects/09/K/KGame.jack
blob: 796f5b5b58f355f6f83ac1a9881cd3aa70f8887d (plain) (blame)
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
class KGame{
    field Board board;

    constructor KGame new() {
        let board = Board.new();
        do board.draw();
        return this;
    }

    method void dispose() {
        do board.dispose();
        do Memory.deAlloc(this);
        return;
    }

    method void run() {
        var int key, dir;
        var boolean exit;
        let key = 0;
        let exit = false;
        while (~exit) {
            while ((key < 130) | (key > 133)) {
                let key = Keyboard.keyPressed();
            }
            let dir = key - 130;
            while (~(key = 0)) {
                let key = Keyboard.keyPressed();
            }
            do board.next(dir);
            do board.draw();
        }
        return;
    }
}