add show map command

cannot save in map
draw orientation
This commit is contained in:
quenousimporte 2025-04-17 17:44:33 +02:00
parent 0265c3a8d0
commit d1003a09d6
1 changed files with 23 additions and 9 deletions

32
w/w.c
View File

@ -20,6 +20,7 @@
#define CMD_BACKTOSTATION 'r' #define CMD_BACKTOSTATION 'r'
#define CMD_GOTOMAZE 'v' #define CMD_GOTOMAZE 'v'
#define CMD_GOTOMARKET 'm' #define CMD_GOTOMARKET 'm'
#define CMD_SHOWMAP 'm'
#define SC_TITLE 0 #define SC_TITLE 0
#define SC_SETNAME 1 #define SC_SETNAME 1
@ -29,6 +30,7 @@
#define SC_GAMEOVER 5 #define SC_GAMEOVER 5
#define SC_WON 6 #define SC_WON 6
#define SC_MARKET 7 #define SC_MARKET 7
#define SC_SHOWMAP 8
#define NORTH 0 #define NORTH 0
#define EAST 1 #define EAST 1
@ -726,6 +728,8 @@ void update(char* command)
gotostation(); gotostation();
} }
break; break;
case CMD_SHOWMAP:
state.screen = SC_SHOWMAP;
default: default:
break; break;
} }
@ -839,6 +843,10 @@ void update(char* command)
} }
} }
} }
else if (state.screen == SC_SHOWMAP)
{
state.screen = SC_MAP;
}
} }
void draw() void draw()
@ -879,19 +887,21 @@ void draw()
else if (state.screen == SC_MAP) else if (state.screen == SC_MAP)
{ {
update3dpov(); update3dpov();
drawmap();
drawpov3d(); drawpov3d();
printf("\n\n Orientation : ");
switch (state.position.orientation)
{
case NORTH: printf("nord"); break;
case EAST: printf("est"); break;
case SOUTH: printf("sud"); break;
case WEST: printf("ouest"); break;
}
if (charatpos(state.position.x, state.position.y) == TILE_START) if (charatpos(state.position.x, state.position.y) == TILE_START)
{ {
printf("\n\nr: Retour à la station\n"); printf("\n\nr: Retour à la station");
} }
else
{
printf("\n ^\n");
printf(" <w s x>\n");
}
//drawmap();
} }
else if (state.screen == SC_STATION) else if (state.screen == SC_STATION)
{ {
@ -934,6 +944,10 @@ void draw()
printf("\nr: Retour à la station\n"); printf("\nr: Retour à la station\n");
} }
else if (state.screen == SC_SHOWMAP)
{
drawmap();
}
if (state.screen != SC_TITLE && state.screen != SC_SETNAME) if (state.screen != SC_TITLE && state.screen != SC_SETNAME)
{ {
@ -986,7 +1000,7 @@ int main()
char command[CMD_LEN] = CMD_NULL; char command[CMD_LEN] = CMD_NULL;
while (command[0] != 'q' || state.screen == SC_MONSTER) while (command[0] != 'q' || state.screen != SC_STATION)
{ {
update(command); update(command);
draw(); draw();