start rogue map

This commit is contained in:
quenousimporte 2025-04-07 20:14:10 +00:00
parent f2eb437ac1
commit 8279703f9b
1 changed files with 21 additions and 14 deletions

27
w/w.c
View File

@ -9,6 +9,7 @@
#define POV_3D_SIZE 10 #define POV_3D_SIZE 10
#define POV_SIZE 3 #define POV_SIZE 3
#define INVENTORY_SIZE 2 #define INVENTORY_SIZE 2
#define MAP_SIZE 15
#define CMD_NULL "-" #define CMD_NULL "-"
#define CMD_FWD 's' #define CMD_FWD 's'
@ -38,6 +39,7 @@
#define TILE_FREE ' ' #define TILE_FREE ' '
#define TILE_DOOR 'd' #define TILE_DOOR 'd'
#define TILE_START 's' #define TILE_START 's'
#define TILE_UNKNOWN '?'
#define ITEM_POTION '0' #define ITEM_POTION '0'
#define ITEM_TRUC '1' #define ITEM_TRUC '1'
@ -86,8 +88,9 @@ Character currentmonster;
Round* firstround = NULL; Round* firstround = NULL;
Round* currentround = NULL; Round* currentround = NULL;
int mapsize = 15; //int mapsize = 15;
char map[15][15] = {
/*char map[15][15] = {
"wwwwwwwwwwwwwww", "wwwwwwwwwwwwwww",
"w w", "w w",
"w wwwww wwwww w", "w wwwww wwwww w",
@ -103,7 +106,9 @@ char map[15][15] = {
"w w w w", "w w w w",
"w w", "w w",
"wwwwwwwwwwwwwww" "wwwwwwwwwwwwwww"
}; };*/
char map[MAP_SIZE * MAP_SIZE];
Character monsters[2] = { Character monsters[2] = {
{ "alien bleu", 2, 2, 1, 1 }, { "alien bleu", 2, 2, 1, 1 },
@ -127,17 +132,17 @@ int dices(int count)
char charatpos(int x, int y) 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 ' ';
} }
return map[y][x]; return map[y * MAP_SIZE + x];
} }
void drawmap() void drawmap()
{ {
for (int y = 0; y < mapsize; y++) { for (int y = 0; y < MAP_SIZE; y++) {
for (int x = 0; x < mapsize; x++) { for (int x = 0; x < MAP_SIZE; x++) {
char toprint = charatpos(x,y); char toprint = charatpos(x,y);
if (y == state.position.y && x == state.position.x) if (y == state.position.y && x == state.position.x)
{ {
@ -446,6 +451,7 @@ void clearscreen()
void init() void init()
{ {
memset(&map, TILE_UNKNOWN, MAP_SIZE * MAP_SIZE);
srand(time(NULL)); srand(time(NULL));
FILE* file = fopen(statepath, "r"); FILE* file = fopen(statepath, "r");
if (file) if (file)
@ -524,7 +530,8 @@ void freerounds()
void gotomonster() void gotomonster()
{ {
int index = dice() == 6 ? 1 : 0; //int index = dice() == 6 ? 1 : 0;
int index = 0;
memcpy(&currentmonster, &(monsters[index]), sizeof(Character)); memcpy(&currentmonster, &(monsters[index]), sizeof(Character));
state.screen = SC_MONSTER; state.screen = SC_MONSTER;
} }
@ -749,8 +756,8 @@ void draw()
else if (state.screen == SC_MAP) else if (state.screen == SC_MAP)
{ {
update3dpov(); update3dpov();
drawpov3d(); //drawpov3d();
//drawmap(); drawmap();
if (charatpos(state.position.x, state.position.y) == TILE_START) if (charatpos(state.position.x, state.position.y) == TILE_START)
{ {