aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/defaults.h1
-rw-r--r--src/game/entry.c6
-rw-r--r--src/game/game.c1
-rw-r--r--src/game/game.h3
-rw-r--r--src/game/operations.c8
-rw-r--r--src/game/operations.h4
6 files changed, 17 insertions, 6 deletions
diff --git a/src/defaults.h b/src/defaults.h
index 0719656..f224da3 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -39,6 +39,7 @@ static inline void set_blocks(struct game_blocks *game_blocks)
{0, "^L", move_maze, MOVE_RIGHT}, \
{'0', "", move_maze, MOVE_BEGINNING}, \
{'p', "", turn_display_switch, DISP_PATH}, \
+ {'v', "", turn_visible, 0}, \
{'q', "", quit, GR_QUIT}, \
{'r', "", new_random, 0}, \
{'c', "", center, 0}, \
diff --git a/src/game/entry.c b/src/game/entry.c
index e4eb033..82ef465 100644
--- a/src/game/entry.c
+++ b/src/game/entry.c
@@ -99,7 +99,7 @@ void draw_maze(struct maze_display *maze_draw, struct game_blocks *blocks)
if (real_x >= 0 && real_x < width)
{
path_sign = maze_draw->signs[cell.x][cell.y];
- if (!visible(maze_draw->maze, maze_draw->player_pos, cell))
+ if (!visible(maze_draw->maze, maze_draw->player_pos, cell) && !(maze_draw->visible))
{
darw_block(&(blocks->hidden));
}
@@ -125,13 +125,13 @@ void draw_maze(struct maze_display *maze_draw, struct game_blocks *blocks)
mv_draw_block(
maze_draw->maze_pos.y + maze_draw->player_pos.y,
maze_draw->maze_pos.x + maze_draw->player_pos.x, &(blocks->player));
- if (visible(maze_draw->maze, maze_draw->player_pos, maze_draw->maze->starting_point))
+ if (visible(maze_draw->maze, maze_draw->player_pos, maze_draw->maze->starting_point) && maze_draw->visible)
{
mv_draw_block(
maze_draw->maze_pos.y + maze_draw->maze->starting_point.y,
maze_draw->maze_pos.x + maze_draw->maze->starting_point.x, &(blocks->start));
}
- if (visible(maze_draw->maze, maze_draw->player_pos, maze_draw->maze->end_point))
+ if (visible(maze_draw->maze, maze_draw->player_pos, maze_draw->maze->end_point) && maze_draw->visible)
{
mv_draw_block(
maze_draw->maze_pos.y + maze_draw->maze->end_point.y,
diff --git a/src/game/game.c b/src/game/game.c
index a9ac239..a5f4ce0 100644
--- a/src/game/game.c
+++ b/src/game/game.c
@@ -83,6 +83,7 @@ struct game_state *create_game_state(struct maze *maze)
display->maze = maze;
display->player_pos = maze->starting_point;
display->display_player_path = true;
+ display->visible = false;
//Signs
int signs_length = sizeof_2d(maze->width, maze->height, sizeof(int));
display->signs = malloc(signs_length);
diff --git a/src/game/game.h b/src/game/game.h
index 4b0de07..d00aaff 100644
--- a/src/game/game.h
+++ b/src/game/game.h
@@ -26,6 +26,7 @@ struct maze_display
struct maze *maze;
enum signs **signs;
bool display_player_path;
+ bool visible;
};
struct game_state
@@ -64,4 +65,4 @@ static inline struct point get_player_center(struct point player_pos)
return maze_pos;
}
-#endif \ No newline at end of file
+#endif
diff --git a/src/game/operations.c b/src/game/operations.c
index aa9424f..7ba3319 100644
--- a/src/game/operations.c
+++ b/src/game/operations.c
@@ -75,6 +75,12 @@ enum op_res turn_display_switch(struct game_state *state, int data)
return OPR_NONE;
}
+enum op_res turn_visible(struct game_state *state, int data)
+{
+ state->display->visible = !state->display->visible;
+ return OPR_NONE;
+}
+
enum op_res new_random(struct game_state *state, int data)
{
struct maze_display *display = state->display;
@@ -141,4 +147,4 @@ enum op_res start_command_prompt(struct game_state *state, int data)
}
}
return OPR_NONE;
-} \ No newline at end of file
+}
diff --git a/src/game/operations.h b/src/game/operations.h
index 2f2af47..36327ad 100644
--- a/src/game/operations.h
+++ b/src/game/operations.h
@@ -31,6 +31,8 @@ enum op_res quit(struct game_state *state, int data);
enum op_res turn_display_switch(struct game_state *state, int data);
+enum op_res turn_visible(struct game_state *state, int data);
+
enum op_res new_random(struct game_state *state, int data);
enum op_res center(struct game_state *state, int data);
@@ -41,4 +43,4 @@ enum op_res solve(struct game_state *state, int data);
enum op_res start_command_prompt(struct game_state *state, int data);
-#endif \ No newline at end of file
+#endif