-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes
192 lines (123 loc) · 5.71 KB
/
notes
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
Ideas :
- add a proper death screen
### Installation of MLX42
In the very end a library is generated, compile your program with this library!
1. Install Homebrew42
(https://github.com/kube/42homebrew)
2. Install GLFW
- brew update
* brew upgrade
3. [Download and build MLX42]
- cd libs
* git clone https://github.com/codam-coding-college/MLX42.git
- cd MLX42
- make
- cd ../..
The output library file is called `libmlx42.a`.
4. Compile Program
With Homebrew42 you have additionally specify the location of the library like here:
- gcc <SRC_FILES> libmlx42.a -I include -lglfw -L "/Users/$USER/.brew/opt/glfw/lib/"
5. Run!
======= COMENTED CODE =======
//gcc -Werror -Wextra -Wall ./src/* ./libs/MLX42/libmlx42.a -I include -lglfw -L "/Users/$USER/.brew/opt/glfw/lib/"
//printf(" Extracted level #%i as :\n\n%s\n", md->lvl_c, md->levels[md->lvl_c]); //REMOVE ME
//printf(" Level : \n\n%s\n", md->levels[md->lvl_c]); //REMOVE ME
//printf(" Board size is %i (%ix%i)\n", d->board_s, d->max_bx + 1, d->max_by + 1); //REMOVE ME
//printf(" Map has been validated!\n"); //REMOVE ME
//printf(" Flag collected! %i flags left\n", d->flg_c); //REMOVE ME
//printf(" Enemy #%i moved to tile (%i,%i)\n", id, dst_tile->bc->x, dst_tile->bc->y); //REMOVE ME
//printf(" Flags distance map reloaded!\n"); //REMOVE ME
//printf(" Player distance map reloaded!\n"); //REMOVE ME
//mlx_put_string(d->window, "Moved", 4, 4); //REMOVE ME
//mlx_put_string(d->window, "Blocked", 4, 4); //REMOVE ME
//puts values in fields used later on to prevent garbage affecting the program
static void set_board_data(t_data *d)
{
d->m_flag = 0; //re_rendering flag (default)
d->c_flag = 0; //asset cleaning flag (default)
d->flg_c = 0; //flags left flag (default)
d->mv_c = 0; //move number flag (default)
d->max_bx = 0; //board width (uninitialized)
d->max_by = 0; //board height (uninitialized)
d->board_s = 0; //tile amount (uninitialized)
d->asset_n = 7; //number of assets (constant)
d->asset_s = 64; //asset resolution (constant)
d->old = NULL; //previously used assets (uninitialized)
d->md->state = STATE_CLOSING; //prevents constant restarting (default)
}
//puts values in fields used later one to prevent garbage affecting the program
static void set_game_data(t_meta *md)
{
md->difficulty = 6; //from 0 to 8 (higher = enemies move smarter)
md->instability = 4; //from 0 to 8 (higher = enemies move more)
md->char_limit = 1560; //how many char a .ber can have (1560 = 39x(39 + \n))
md->max_size = 75; //maximum dimensions of the board (bx + by) (38x38 - 1)
md->no_checks = 0; //wether to ignore the initial parsing checks or not
md->try_c = 0; //default value for starting first level
md->try_n = 0; //default value for starting first level
md->state = STATE_RETRYING; //default value for starting first level
}
//initiate the window and window related fields REMOVED
static void initiate_window(t_data *d)
{
d->max_wx = (d->max_bx + d->max_by + 3) * d->asset_s / 2;
d->max_wy = (d->max_bx + d->max_by + 5) * d->asset_s / 4;
d->window = mlx_init(d->max_wx, d->max_wy, "So Round", true);
d->tittle = make_image(d, "./assets/XPM/Tittle.xpm42");
mlx_image_to_window(d->window, d->tittle, 0, 0);
}
typedef struct s_tile
{
t_coords *bc; //tile coordinates
mlx_image_t *floor; //floor image instance
mlx_image_t *object; //object image instance
struct s_tile *north; //northern neighbor
struct s_tile *east; //eastern neighbor
struct s_tile *south; //southern neighbor
struct s_tile *west; //western neighbor
int type; //see e_type TYPES
int dst_f; //current distance to flags / end
int dst_p; //current distance to player
} t_tile;
typedef struct s_meta //data for the entire game (aka over multiple boards/levels)
{
char **levels; //list of all levels
time_t time; //used to seed srand()
int state; //see e_state STATES
int difficulty; //odds over 8 that the enemies won't take a random move
int instability; //chances over n that a random move won't leave enemy put
int char_limit; //maximum nb of chars in a .ber file
int max_size; //maximum lenght or width of the map
int no_checks; //whether or not to do the initial checks on the input
int mv_c; //current amount of movement
int try_c; //current amount of level (re)started
int try_n; //total amount of attempted levels
int lvl_c; //current level
int lvl_n; //total amount of levels
} t_meta;
typedef struct s_data //data for the current board only
{
int max_wx; //width (in pixels) of the window
int max_wy; //height (in pixels) of the window
mlx_t *window; //where we print stuff
int max_bx; //width (in tiles) of the board
int max_by; //height (in tiles) of the board
int board_s; //number of tiles in the board
t_tile **tiles; //lists all tiles
int asset_s; //size (in pixels) of assets used (64 pixels)
int asset_n; //number of distinct assets used (7 assets)
mlx_image_t **assets; //array of currently used assets
mlx_image_t **old; //array of previously used assets
mlx_image_t *tittle; //tittle image (never reloaded)
t_coords **enemies; //enemy positions
t_coords *pc; //player position
t_coords *ec; //end position
int m_flag; //whether the player has moved or not (wether to render or not)
int c_flag; //whether to clean old assets
int flg_c; //number of flags left to collect on this board
int mv_c; //number of moves done on this board
int nm_n; //number of enemies on this board
t_meta *md; //game metadata
} t_data;
*/