diff --git a/src/linux.h b/src/linux.h new file mode 100644 index 0000000..526b709 --- /dev/null +++ b/src/linux.h @@ -0,0 +1,20 @@ +#include + +int fuck(void) { + return 69; +} +int zom_scrinit(void) { + initscr(); + nodelay(stdscr, true);//cbreak would wait for you to press a key this doesnt + noecho(); + clear(); + return 0; +} +int zom_screxit(void) { + endwin(); + return 0; +} +int zom_putcharat(int x, int y, char chara){ + mvaddch(y, x, chara); + return 0; +} diff --git a/src/main.c b/src/main.c index 2301983..30a1a2b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ #include //printf and shit -#include #include +#include "linux.h" int main( int argc, char *argv[] ) { //yoinked from the internet argc is number of args and argv is a "array of arguments" @@ -24,12 +24,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number debugent_x = {0, 0, 0, 0}, debugent_y = {0, 0, 0, 0}; - initscr(); - //cbreak(); - nodelay(stdscr, true);//cbreak would wait for you to press a key this doesnt - noecho(); - - clear(); + zom_scrinit(); while(gamerun) { currenttime = clock(); @@ -46,19 +41,19 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number switch (getch()) { case 'a': - player.y--; - break; - - case 'w': player.x--; break; + case 'w': + player.y--; + break; + case 'd': - player.y++; + player.x++; break; case 's': - player.x++; + player.y++; break; case 'q': @@ -76,7 +71,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number } //game logic not kb dependent if ((enemy.x == player.x) && (enemy.y == player.y)){ - endwin(); + zom_screxit(); puts("you lose :("); return 0; //TODO fix this this should not be here... } @@ -92,33 +87,32 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number prevtime = currenttime; } //entity rendering - mvaddch(enemy.xold, enemy.yold, ' '); + zom_putcharat(enemy.xold, enemy.yold, ' '); switch (dosspin) { case 0: - mvaddch(enemy.x, enemy.y, '-'); + zom_putcharat(enemy.x, enemy.y, '-'); break; case 1: - mvaddch(enemy.x, enemy.y, '/'); + zom_putcharat(enemy.x, enemy.y, '/'); break; case 2: - mvaddch(enemy.x, enemy.y, '|'); + zom_putcharat(enemy.x, enemy.y, '|'); break; case 3: - mvaddch(enemy.x, enemy.y, '\\'); + zom_putcharat(enemy.x, enemy.y, '\\'); break; } - mvaddch(player.xold, player.yold, ' '); - mvaddch(player.x, player.y, '#'); - mvaddch(debugent_x.xold, debugent_x.yold, ' '); - mvaddch(debugent_x.x, debugent_x.y, 'X'); - mvaddch(debugent_y.xold, debugent_y.yold, ' '); - mvaddch(debugent_y.x, debugent_y.y, 'Y'); + zom_putcharat(player.xold, player.yold, ' '); + zom_putcharat(player.x, player.y, '#'); + zom_putcharat(debugent_x.xold, debugent_x.yold, ' '); + zom_putcharat(debugent_x.x, debugent_x.y, 'X'); + zom_putcharat(debugent_y.xold, debugent_y.yold, ' '); + zom_putcharat(debugent_y.x, debugent_y.y, 'Y'); } //cleanup - endwin(); - + zom_screxit(); printf("Args %d",argc); //anti Wall Werror Wextra puts(argv[0]);//anti Wall Werror Wextra