diff --git a/src/main.c b/src/main.c index e565991..6c9b20a 100644 --- a/src/main.c +++ b/src/main.c @@ -152,34 +152,6 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number } else {enemy.y++;} } - /* - TODO clean this shit up - this should apply to everything not just the player - it should also be generalized to all entitys using a for loop or somthing - */ - - //anti go off screen - - if (player.x < 0) { - player.x = 0; - } - - if (player.x > (scrwidth - 1)) { - player.x = scrwidth - 1; - } - if (player.y < 0) { - player.y = 0; - } - - if (player.y > (scrheight - 1)) { - player.y = scrheight - 1; - } - - - //scrwidth - 1 bc zero indexed moment - - - prevtime = currenttime; } diff --git a/src/map.h b/src/map.h index cdd63ff..555ebad 100644 --- a/src/map.h +++ b/src/map.h @@ -1,10 +1,22 @@ char readmap(int x, int y) { + if (x > (mapwidth - 1)) { + return '&'; + } + if (y > (mapheight - 1)) { + return '&'; + } + if (x < 0) { + return '&'; + } + if (y < 0) { + return '&'; + } + return maptest[y][x]; //TODO make it be able to rrad feom multiple maps but idk how to do that } int render_map(void) { int x; int y; - //I think this is broken but maybe with with the border code idk TODO fix for(y = 0; y < 40; y++) { for(x = 0; x < 80; x++) { zom_putcharat(x, y, readmap(x, y)); diff --git a/src/maptest.h b/src/maptest.h index 5c0af1e..1e10ef6 100644 --- a/src/maptest.h +++ b/src/maptest.h @@ -1,4 +1,6 @@ //TODO make this read from a file instead of from this array pile +int mapwidth = 80; +int mapheight = 40; char maptest[40][80] = { {'1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2'}, {'2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2'},