back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/field.h
blob: 728d75ab187893a1a36cfebb9a3e929be1bdca7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef FIELD_H_SENTRY
#define FIELD_H_SENTRY

enum {
    field_width             = 28,
    field_height            = 30,
    left_outside_tunnel_x   = -1,
    right_outside_tunnel_x  = field_width,
    door                    = '#',
    block                   = '/',
    coin                    = '.',
    energizer               = '*'
};

enum intersection_type {
    one_path     = '1',
    two_paths    = '2',
    three_paths  = '3',
    yellow_block = 'y',
    direct_path
};

enum select_character {
    ghost_char = '&',
    pac_char = 'C'
};

typedef char (*game_space)[field_width];
game_space get_new_field();

struct free_directions {
    int left;
    int right;
    int up;
    int down;
};

void print_field(game_space field);

void display_character(int y, int x, int symbol, int prison_status);

struct ghost_type;
void display_ghosts_on_field(struct ghost_type *red_ghost,
                             struct ghost_type *pink_ghost,
                             struct ghost_type *blue_ghost,
                             struct ghost_type *orange_ghost,
                             int frightened_counter);
void display_score(int value);
void display_ready();

struct coordinates;
void display_hit(struct coordinates pac_position,
                 const struct ghost_type *red_ghost,
                 const struct ghost_type *pink_ghost,
                 const struct ghost_type *blue_ghost,
                 const struct ghost_type *orange_ghost);

struct queue;
void clear_or_revert_symbol(game_space field, struct coordinates position,
                            enum select_character character,
                            const struct queue *eaten_coins);

void clear_energizer(game_space field, struct coordinates point);
void clear_field(game_space *field);
void clear_ready();

enum intersection_type get_intersection(const game_space field,
                                        struct ghost_type *ghost);

struct free_directions find_free_directions(game_space field, int y, int x);

int is_obstacle(game_space field, int x, int y);


int check_coin_for_pac(game_space field, struct coordinates position,
                       struct queue *eaten_coins);

int field_has_energizer(const game_space field, int x, int y);

void change_point_if_outside_tunnel(struct coordinates *point);

int is_equal_points(struct coordinates first_point, struct coordinates
                    second_point);

void erase_life(int value);
void erase_hit(struct coordinates point);

#endif