forked from abunai59/umouse2013
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcell.c
84 lines (78 loc) · 1.56 KB
/
cell.c
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
// cell.c
// functions for cells
#include <stdbool.h>
#include <stdlib.h>
#include "cell.h"
// initialize cell
void init_cell(Cell * cell, int x, int y) {
if(cell != NULL) {
del_s_wall(cell); // set south wall to false
del_w_wall(cell); // set west wall to false
set_pos(cell,x,y); // set the position of the cell
}
}
// functions on south wall
void set_s_wall(Cell * cell) {
if(cell != NULL) {
cell->s_wall = true;
}
}
void del_s_wall(Cell * cell) {
if(cell != NULL) {
cell->s_wall = false;
}
}
bool has_s_wall(Cell * cell) {
if(cell != NULL) {
return cell->s_wall;
}
else return true;
}
// functions on west wall
void set_w_wall(Cell * cell) {
if(cell != NULL) {
cell->w_wall = true;
}
}
void del_w_wall(Cell * cell) {
if(cell != NULL) {
cell->w_wall = false;
}
}
bool has_w_wall(Cell * cell) {
if(cell != NULL) {
return cell->w_wall;
}
else return true;
}
// functions on cell value
void set_val(Cell * cell, int val) {
if(cell != NULL) {
cell->val = val;
}
}
int get_val(Cell * cell) {
if(cell != NULL) {
return cell->val;
}
else return INF_CELL;
}
// functions on cell position
void set_pos(Cell * cell, int x, int y) {
if(cell != NULL) {
cell->x = x;
cell->y = y;
}
}
int get_x(Cell * cell) {
if(cell != NULL) {
return cell->x;
}
else return NOX_CELL;
}
int get_y(Cell * cell) {
if(cell != NULL) {
return cell->y;
}
else return NOY_CELL;
}