-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (44 loc) · 1.26 KB
/
main.cpp
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
#include<ncursesw/cursesw.h>
#include<iostream>
#include "header/map.hpp"
int main(int argc, char const *argv[])
{
int a = 0;
Map* playMap = new Map(10,10);
std::cin >> a;
playMap->init();//wir muessen irgendwo starten
initscr();//Initialisisre ncurses
cbreak();//Output Buffer und kei Line Break
keypad(stdscr, TRUE);
int key;
while(1){//Game Loop, ich weiss nicht toll aber ey
int height = playMap->getHeight();
std::string buffer = "";
for(int ih = 0; ih < height; ih++){
buffer.append(playMap->playRow(ih));
mvaddstr(ih,0, buffer.c_str()); //Buffer neu Bauen
buffer.clear(); //muessen dann ja wieder frei machen
}
refresh(); //Buffer tauschen
bool possibleToMove = playMap->calculateValidMoves();
if(possibleToMove == false){
break;
}
key = getch(); //key einlesen
if(key == KEY_UP){
playMap->shiftUp();
}
if(key == KEY_LEFT){
playMap->shiftLeft();
}
if(key == KEY_DOWN){
playMap->shiftDown();
}
if(key == KEY_RIGHT){
playMap->shiftRight();
}
}
endwin(); //ncurses kann sich wieder verpissen
std::cout << "Du hast verkackt du Bonobo" << std::endl;
return 0;
}