summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 022a2aa38b52c801a0d94546e70f9ccfad6777c1 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "main.hpp"

int main()
{
    Screen s;

    Frame map("scripts/map.txt",0,0);
    Frame view(map,s.getHeight(),s.getWidth(),0,0);
    List L;
    
    Location l;
    l.x =150;
    l.y =150;
    Character cursor('X',3,l);

    map.fillWindow();
    L.draw(map.getWin());
    cursor.draw(map.getWin());
    
    bool paused = false;
    while(true)
    {
        char c = getch();
        Location l = cursor.getLocation();
        if	(c == 'h')
            l.y = l.y-1;
        else if	(c == 'l')
            l.y = l.y+1;
        else if	(c == 'k')
            l.x = l.x+1;
        else if	(c == 'j')
            l.x = l.x-1;
        else if	(c == 'q')
            	break;
        else if (c == 'p')
        {
            if  (paused)
            {
                timeout(100);
                paused = false;
            }
            else
            {
                timeout(-1);
                paused = true;
            }
        }
        
        cursor.move(l);
        if (!paused)
            L.action();
        map.fillWindow();
        L.draw(map.getWin());
        cursor.draw(map.getWin());
        view.center(cursor);
    }

    return 0;
}