From 8279703f9bb4bba8b6f55b6e0e38c5c93ba8d319 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 7 Apr 2025 20:14:10 +0000 Subject: [PATCH] start rogue map --- w/w.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/w/w.c b/w/w.c index 846e964..5ad6047 100644 --- a/w/w.c +++ b/w/w.c @@ -9,6 +9,7 @@ #define POV_3D_SIZE 10 #define POV_SIZE 3 #define INVENTORY_SIZE 2 +#define MAP_SIZE 15 #define CMD_NULL "-" #define CMD_FWD 's' @@ -34,10 +35,11 @@ #define WEST 2 #define SOUTH 3 -#define TILE_WALL 'w' -#define TILE_FREE ' ' -#define TILE_DOOR 'd' -#define TILE_START 's' +#define TILE_WALL 'w' +#define TILE_FREE ' ' +#define TILE_DOOR 'd' +#define TILE_START 's' +#define TILE_UNKNOWN '?' #define ITEM_POTION '0' #define ITEM_TRUC '1' @@ -86,8 +88,9 @@ Character currentmonster; Round* firstround = NULL; Round* currentround = NULL; -int mapsize = 15; -char map[15][15] = { +//int mapsize = 15; + +/*char map[15][15] = { "wwwwwwwwwwwwwww", "w w", "w wwwww wwwww w", @@ -103,7 +106,9 @@ char map[15][15] = { "w w w w", "w w", "wwwwwwwwwwwwwww" -}; +};*/ + +char map[MAP_SIZE * MAP_SIZE]; Character monsters[2] = { { "alien bleu", 2, 2, 1, 1 }, @@ -127,17 +132,17 @@ int dices(int count) char charatpos(int x, int y) { - if (x < 0 || y < 0 || x >= mapsize || y >= mapsize) + if (x < 0 || y < 0 || x >= MAP_SIZE || y >= MAP_SIZE) { return ' '; } - return map[y][x]; + return map[y * MAP_SIZE + x]; } void drawmap() { - for (int y = 0; y < mapsize; y++) { - for (int x = 0; x < mapsize; x++) { + for (int y = 0; y < MAP_SIZE; y++) { + for (int x = 0; x < MAP_SIZE; x++) { char toprint = charatpos(x,y); if (y == state.position.y && x == state.position.x) { @@ -446,6 +451,7 @@ void clearscreen() void init() { + memset(&map, TILE_UNKNOWN, MAP_SIZE * MAP_SIZE); srand(time(NULL)); FILE* file = fopen(statepath, "r"); if (file) @@ -524,7 +530,8 @@ void freerounds() void gotomonster() { - int index = dice() == 6 ? 1 : 0; + //int index = dice() == 6 ? 1 : 0; + int index = 0; memcpy(¤tmonster, &(monsters[index]), sizeof(Character)); state.screen = SC_MONSTER; } @@ -749,8 +756,8 @@ void draw() else if (state.screen == SC_MAP) { update3dpov(); - drawpov3d(); - //drawmap(); + //drawpov3d(); + drawmap(); if (charatpos(state.position.x, state.position.y) == TILE_START) {