back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/field.c
diff options
context:
space:
mode:
Diffstat (limited to 'field.c')
-rw-r--r--field.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/field.c b/field.c
index 5bcb813..a795f8e 100644
--- a/field.c
+++ b/field.c
@@ -1,5 +1,6 @@
#include "field.h"
#include "ghosts.h"
+#include "queue.h"
#include <ncurses.h>
#include <stdlib.h>
@@ -52,11 +53,11 @@ game_space get_new_field()
return field;
}
-static int is_has_point(int i, int j)
+int field_has_coin(int x, int y)
{
- return !((i == 12 && j == 9) || (i == 12 && j == 18) ||
- (i == 14 && j == 18) || (i == 15 && j == 9) ||
- (i == 17 && j == 9) || (i == 17 && j == 18));
+ return !((x == 12 && y == 9) || (x == 12 && y == 18) ||
+ (x == 14 && y == 18) || (x == 15 && y == 9) ||
+ (x == 17 && y == 9) || (x == 17 && y == 18));
}
void print_field(game_space field)
@@ -72,7 +73,7 @@ void print_field(game_space field)
case '1':
case '2':
case '3':
- if(is_has_point(i, j))
+ if(field_has_coin(i, j))
addch('.');
else
addch(' ');
@@ -113,18 +114,32 @@ void display_ghosts_on_field(struct ghost_type *red_ghost,
ghost_char);
}
-void eat_or_revert_symbol(game_space field, int y, int x,
- enum select_character character)
+void clear_or_revert_symbol(game_space field, struct coordinates position,
+ enum select_character character,
+ struct queue *eaten_coins)
{
+ int x, y;
+ x = position.x;
+ y = position.y;
int symbol = field[y][x];
move(y, x);
if(character == ghost_char) {
switch(symbol) {
- case '#':
+ case one_path:
+ case two_paths:
+ case three_paths:
+ if(field_has_coin(y, x))
+ queue_consists_point(eaten_coins, position) ?
+ addch(' ') : addch('.');
+ else
+ addch(' ');
+ break;
+ case door:
addch('#');
break;
- case '.':
- addch('.');
+ case coin:
+ queue_consists_point(eaten_coins, position) ?
+ addch(' ') : addch('.');
break;
case ' ':
addch(' ');