makes it so tiles dont get deleted when walked over
this adds a critical bug of where if you somehow walk outside the map the game will segfault
This commit is contained in:
parent
5d2b3b0c95
commit
97aac29626
1 changed files with 15 additions and 7 deletions
22
src/main.c
22
src/main.c
|
@ -35,20 +35,23 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
int delay = 1000;
|
int delay = 1000;
|
||||||
int dosspin = 0;
|
int dosspin = 0;
|
||||||
|
|
||||||
|
//TODO nuke bools they arnt part of the c99 standard
|
||||||
|
//here it js being stolen from curses
|
||||||
bool gamerun = true;
|
bool gamerun = true;
|
||||||
|
|
||||||
struct entity {
|
struct entity {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int xold;
|
int xold; //i kinda dont like tbid xold yold shit
|
||||||
int yold;
|
int yold;
|
||||||
|
char under_char; //the char that is under the entity so when it moves off of it it wont be erased
|
||||||
|
char under_charold;
|
||||||
}
|
}
|
||||||
|
|
||||||
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_x = {0, 0, 0, 0, ' ', ' '},
|
||||||
debugent_y = {0, 0, 0, 0};
|
debugent_y = {0, 0, 0, 0, ' ', ' '};
|
||||||
|
|
||||||
zom_scrinit();
|
zom_scrinit();
|
||||||
|
|
||||||
|
@ -64,6 +67,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
if ((currenttime % 5000)==0) {
|
if ((currenttime % 5000)==0) {
|
||||||
player.xold = player.x;
|
player.xold = player.x;
|
||||||
player.yold = player.y;
|
player.yold = player.y;
|
||||||
|
player.under_charold = player.under_char;
|
||||||
enemy.xold = enemy.x;
|
enemy.xold = enemy.x;
|
||||||
enemy.yold = enemy.y;
|
enemy.yold = enemy.y;
|
||||||
debugent_x.xold = debugent_x.x;
|
debugent_x.xold = debugent_x.x;
|
||||||
|
@ -75,24 +79,28 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
case 'a':
|
case 'a':
|
||||||
if (attempt_move(player.x, player.y, 1, 2) == 1) {
|
if (attempt_move(player.x, player.y, 1, 2) == 1) {
|
||||||
player.x--;
|
player.x--;
|
||||||
|
player.under_char = readmap(player.x, player.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
if (attempt_move(player.x, player.y, 1, 1) == 1) {
|
if (attempt_move(player.x, player.y, 1, 1) == 1) {
|
||||||
player.y--;
|
player.y--;
|
||||||
|
player.under_char = readmap(player.x, player.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
if (attempt_move(player.x, player.y, 1, 0) == 1) {
|
if (attempt_move(player.x, player.y, 1, 0) == 1) {
|
||||||
player.x++;
|
player.x++;
|
||||||
|
player.under_char = readmap(player.x, player.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (attempt_move(player.x, player.y, 1, 3) == 1) {
|
if (attempt_move(player.x, player.y, 1, 3) == 1) {
|
||||||
player.y++;
|
player.y++;
|
||||||
|
player.under_char = readmap(player.x, player.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -170,7 +178,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
zom_putcharat(player.xold, player.yold, ' ');
|
zom_putcharat(player.xold, player.yold, player.under_charold);
|
||||||
zom_putcharat(player.x, player.y, '#');
|
zom_putcharat(player.x, player.y, '#');
|
||||||
zom_putcharat(debugent_x.xold, debugent_x.yold, ' ');
|
zom_putcharat(debugent_x.xold, debugent_x.yold, ' ');
|
||||||
zom_putcharat(debugent_x.x, debugent_x.y, 'X');
|
zom_putcharat(debugent_x.x, debugent_x.y, 'X');
|
||||||
|
|
Loading…
Reference in a new issue