fixed things idk
This commit is contained in:
parent
d97333c39a
commit
84ce5efc73
2 changed files with 30 additions and 20 deletions
BIN
a.out
BIN
a.out
Binary file not shown.
54
playergame.c
54
playergame.c
|
@ -15,9 +15,11 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
struct entity {
|
struct entity {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
int xold;
|
||||||
|
int yold;
|
||||||
}
|
}
|
||||||
player = {0, 0},
|
player = {0, 0, 0, 0},
|
||||||
enemy = {24, 16};
|
enemy = {24, 16, 0, 0};
|
||||||
|
|
||||||
initscr();
|
initscr();
|
||||||
//cbreak();
|
//cbreak();
|
||||||
|
@ -30,7 +32,10 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
currenttime = clock();
|
currenttime = clock();
|
||||||
dosspin = clock() % 4;
|
dosspin = clock() % 4;
|
||||||
if ((currenttime - prevtime) > delay) {
|
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()) {
|
switch (getch()) {
|
||||||
case 'a' :
|
case 'a' :
|
||||||
|
@ -53,6 +58,25 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
gamerun = false;
|
gamerun = false;
|
||||||
break;
|
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--;
|
||||||
|
} else {enemy.x++;}
|
||||||
|
if (enemy.y > player.y) {
|
||||||
|
enemy.y--;
|
||||||
|
} else {enemy.y++;}
|
||||||
|
}
|
||||||
|
prevtime = currenttime;
|
||||||
|
}
|
||||||
|
//entity rendering
|
||||||
|
mvaddch(enemy.xold, enemy.yold, ' ');
|
||||||
switch (dosspin) {
|
switch (dosspin) {
|
||||||
case 0 :
|
case 0 :
|
||||||
mvaddch(enemy.x, enemy.y, '-');
|
mvaddch(enemy.x, enemy.y, '-');
|
||||||
|
@ -67,30 +91,16 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
mvaddch(enemy.x, enemy.y, '\\');
|
mvaddch(enemy.x, enemy.y, '\\');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//game logic not kb dependent
|
|
||||||
if ((enemy.x == player.x) && (enemy.y == player.y)){
|
mvaddch(player.xold, player.yold, ' ');
|
||||||
endwin();
|
mvaddch(player.x, player.y, '#');
|
||||||
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
|
//cleanup
|
||||||
endwin();
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue