diff --git a/a.out b/a.out index df3696c..8ba520f 100755 Binary files a/a.out and b/a.out differ diff --git a/playergame.c b/playergame.c new file mode 100644 index 0000000..33c5857 --- /dev/null +++ b/playergame.c @@ -0,0 +1,96 @@ +#include //printf and shit +#include +#include + + +int main( int argc, char *argv[] ) { //yoinked from the internet argc is number of args and argv is a "array of arguments" + clock_t prevtime, currenttime; + prevtime = clock(); + int delay = 1000; + int dosspin = 0; + + + bool gamerun = true; + + struct entity { + int x; + int y; + } + player = {0, 0}, + enemy = {24, 16}; + + initscr(); + //cbreak(); + nodelay(stdscr, true); //cbreak would wait for you to press a key this doesnt + noecho(); + + clear(); + + while(gamerun) { + currenttime = clock(); + dosspin = clock() % 4; + if ((currenttime - prevtime) > delay) { + mvaddch(player.x, player.y, ' '); + + switch (getch()) { + case 'a' : + player.y--; + break; + + case 'w' : + player.x--; + break; + + case 'd' : + player.y++; + break; + + case 's' : + player.x++; + break; + + case 'q' : + 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... + } + if ((clock() % 500) == 1) { + if (enemy.x > player.x) { + enemy.x--; + } else {enemy.x++;} + if (enemy.y > player.y) { + enemy.y--; + } else {enemy.y++;} + } + prevtime = currenttime; + } + mvaddch(player.x+1, player.y, '#'); //idk how to fix + } + + //cleanup + endwin(); + + printf("Args %d",argc); + + puts(argv[0]); + return 0; +}