diff --git a/a.out b/a.out index 8ba520f..2147447 100755 Binary files a/a.out and b/a.out differ diff --git a/playergame.c b/playergame.c index 33c5857..5971c83 100644 --- a/playergame.c +++ b/playergame.c @@ -15,9 +15,11 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number struct entity { int x; int y; + int xold; + int yold; } - player = {0, 0}, - enemy = {24, 16}; + player = {0, 0, 0, 0}, + enemy = {24, 16, 0, 0}; initscr(); //cbreak(); @@ -30,7 +32,10 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number currenttime = clock(); dosspin = clock() % 4; if ((currenttime - prevtime) > delay) { - mvaddch(player.x, player.y, ' '); + player.xold = player.x; + player.yold = player.y; + enemy.xold = enemy.x; + enemy.yold = enemy.y; switch (getch()) { case 'a' : @@ -53,26 +58,13 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number gamerun = false; break; } - switch (dosspin) { - case 0 : - mvaddch(enemy.x, enemy.y, '-'); - break; - case 1 : - mvaddch(enemy.x, enemy.y, '/'); - break; - case 2 : - mvaddch(enemy.x, enemy.y, '|'); - break; - case 3 : - mvaddch(enemy.x, enemy.y, '\\'); - break; - } //game logic not kb dependent if ((enemy.x == player.x) && (enemy.y == player.y)){ endwin(); puts("you lose :("); return 0; //TODO fix this this should not be here... } + //TODO fix enemy movement (it works but its kinda broken) if ((clock() % 500) == 1) { if (enemy.x > player.x) { enemy.x--; @@ -83,14 +75,32 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number } prevtime = currenttime; } - mvaddch(player.x+1, player.y, '#'); //idk how to fix + //entity rendering + mvaddch(enemy.xold, enemy.yold, ' '); + switch (dosspin) { + case 0 : + mvaddch(enemy.x, enemy.y, '-'); + break; + case 1 : + mvaddch(enemy.x, enemy.y, '/'); + break; + case 2 : + mvaddch(enemy.x, enemy.y, '|'); + break; + case 3 : + mvaddch(enemy.x, enemy.y, '\\'); + break; + } + + mvaddch(player.xold, player.yold, ' '); + mvaddch(player.x, player.y, '#'); } //cleanup endwin(); - printf("Args %d",argc); + printf("Args %d",argc); //anti Wall Werror Wextra - puts(argv[0]); + puts(argv[0]);//anti Wall Werror Wextra return 0; }