idk what i chnged
This commit is contained in:
parent
84ce5efc73
commit
2486e1dd42
2 changed files with 32 additions and 12 deletions
BIN
a.out
BIN
a.out
Binary file not shown.
44
playergame.c
44
playergame.c
|
@ -18,12 +18,15 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
int xold;
|
int xold;
|
||||||
int yold;
|
int yold;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = {0, 0, 0, 0},
|
player = {0, 0, 0, 0},
|
||||||
enemy = {24, 16, 0, 0};
|
enemy = {24, 16, 0, 0},
|
||||||
|
debugent_x = {0, 0, 0, 0},
|
||||||
|
debugent_y = {0, 0, 0, 0};
|
||||||
|
|
||||||
initscr();
|
initscr();
|
||||||
//cbreak();
|
//cbreak();
|
||||||
nodelay(stdscr, true); //cbreak would wait for you to press a key this doesnt
|
nodelay(stdscr, true);//cbreak would wait for you to press a key this doesnt
|
||||||
noecho();
|
noecho();
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
@ -36,27 +39,40 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
player.yold = player.y;
|
player.yold = player.y;
|
||||||
enemy.xold = enemy.x;
|
enemy.xold = enemy.x;
|
||||||
enemy.yold = enemy.y;
|
enemy.yold = enemy.y;
|
||||||
|
debugent_x.xold = debugent_x.x;
|
||||||
|
debugent_x.yold = debugent_x.y;
|
||||||
|
debugent_y.xold = debugent_y.x;
|
||||||
|
debugent_y.yold = debugent_y.y;
|
||||||
|
|
||||||
switch (getch()) {
|
switch (getch()) {
|
||||||
case 'a' :
|
case 'a':
|
||||||
player.y--;
|
player.y--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w' :
|
case 'w':
|
||||||
player.x--;
|
player.x--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd' :
|
case 'd':
|
||||||
player.y++;
|
player.y++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's' :
|
case 's':
|
||||||
player.x++;
|
player.x++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'q' :
|
case 'q':
|
||||||
gamerun = false;
|
gamerun = false;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
player.x = 9;
|
||||||
|
player.y = 9;
|
||||||
|
break;
|
||||||
|
//debug case
|
||||||
|
case 'l':
|
||||||
|
debugent_x.x++;
|
||||||
|
debugent_y.y++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//game logic not kb dependent
|
//game logic not kb dependent
|
||||||
if ((enemy.x == player.x) && (enemy.y == player.y)){
|
if ((enemy.x == player.x) && (enemy.y == player.y)){
|
||||||
|
@ -65,7 +81,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
return 0; //TODO fix this this should not be here...
|
return 0; //TODO fix this this should not be here...
|
||||||
}
|
}
|
||||||
//TODO fix enemy movement (it works but its kinda broken)
|
//TODO fix enemy movement (it works but its kinda broken)
|
||||||
if ((clock() % 500) == 1) {
|
if ((clock() % 100) == 1) {
|
||||||
if (enemy.x > player.x) {
|
if (enemy.x > player.x) {
|
||||||
enemy.x--;
|
enemy.x--;
|
||||||
} else {enemy.x++;}
|
} else {enemy.x++;}
|
||||||
|
@ -78,22 +94,26 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
//entity rendering
|
//entity rendering
|
||||||
mvaddch(enemy.xold, enemy.yold, ' ');
|
mvaddch(enemy.xold, enemy.yold, ' ');
|
||||||
switch (dosspin) {
|
switch (dosspin) {
|
||||||
case 0 :
|
case 0:
|
||||||
mvaddch(enemy.x, enemy.y, '-');
|
mvaddch(enemy.x, enemy.y, '-');
|
||||||
break;
|
break;
|
||||||
case 1 :
|
case 1:
|
||||||
mvaddch(enemy.x, enemy.y, '/');
|
mvaddch(enemy.x, enemy.y, '/');
|
||||||
break;
|
break;
|
||||||
case 2 :
|
case 2:
|
||||||
mvaddch(enemy.x, enemy.y, '|');
|
mvaddch(enemy.x, enemy.y, '|');
|
||||||
break;
|
break;
|
||||||
case 3 :
|
case 3:
|
||||||
mvaddch(enemy.x, enemy.y, '\\');
|
mvaddch(enemy.x, enemy.y, '\\');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mvaddch(player.xold, player.yold, ' ');
|
mvaddch(player.xold, player.yold, ' ');
|
||||||
mvaddch(player.x, player.y, '#');
|
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
//cleanup
|
//cleanup
|
||||||
|
|
Loading…
Reference in a new issue