forked from protoman/rockbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
classmap.h
297 lines (188 loc) · 7.93 KB
/
classmap.h
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#ifndef CLASSMAP_H
#define CLASSMAP_H
#include "defines.h"
#include "file/format/st_common.h"
#include "graphicslib.h"
#include "character/classnpc.h"
#include "objects/object.h"
#include "graphic/animation.h"
#include <list>
#include <vector>
#define EXPLOSION_ANIMATION_TIME 50
class classPlayer; // forward declaration
class character;
struct object_collision {
int _block;
object* _object;
object_collision(int set_block, object* set_object) {
_block = set_block;
_object = set_object;
}
object_collision() {
_block = 0;
_object = NULL;
}
};
struct water_bubble {
st_position pos;
float x_adjust;
int x_adjust_direction;
float timer;
};
struct st_level3_tile {
st_position tileset_pos;
st_position map_position;
st_level3_tile(st_position set_tileset_pos, st_position set_map_position)
{
tileset_pos = set_tileset_pos;
map_position = set_map_position;
}
st_level3_tile()
{
tileset_pos = st_position(0, 0);
map_position = st_position(0, 0);
}
};
struct anim_tile_desc {
int anim_tile_id;
int dest_x;
int dest_y;
anim_tile_desc(int id, st_position pos) {
anim_tile_id = id;
dest_x = pos.x;
dest_y = pos.y;
}
};
/**
* @brief
*
*/
class classMap
{
public:
classMap();
~classMap();
static bool deleteAll( classMap* theElement );
void setStageNumber(int);
short get_number() const;
void setMapNumber(int);
void loadMap();
void show_map();
void draw_map_tiles();
void draw_animated_tiles(graphicsLib_gSurface &surface);
void init_animated_tiles();
void showAbove(int scroll_y=0, int temp_scroll_x = -99999, bool show_fg=true);
bool is_point_solid(st_position pos) const;
int getMapPointLock(st_position pos) const;
st_position_int8 get_map_point_tile1(st_position pos);
bool get_map_point_wall_lock(int x) const;
void changeScrolling(st_float_position pos, bool check_lock=true);
st_float_position getMapScrolling() const;
st_float_position* get_map_scrolling_ref();
st_float_position get_last_scrolled() const;
void reset_scrolled();
void load_map_objects();
int collision_rect_player_obj(st_rectangle player_rect, object* temp_obj, const short int x_inc, const short int y_inc, const short obj_xinc, const short obj_yinc);
bool is_obj_ignored_by_enemies(Uint8 obj_type); // returns true if object if of type that can be got like energy
void collision_char_object(character*, const float, const short int);
object_collision get_obj_collision();
classnpc* collision_player_npcs(character*, const short int, const short int);
void collision_player_special_attack(character*, const short int, const short int, short int, short int);
classnpc* find_nearest_npc(st_position pos);
classnpc* find_nearest_npc_on_direction(st_position pos, int direction);
void clean_map_npcs_projectiles();
void reset_beam_objects();
void remove_temp_objects();
void get_map_area_surface(graphicsLib_gSurface &mapSurface);
void set_scrolling(st_float_position pos);
void reset_scrolling();
void move_map(const short int move_x, const short int move_y);
void reset_map();
void redraw_boss_door(bool is_close, int nTiles, int tileX, int tileY, short player_number);
void add_animation(ANIMATION_TYPES pos_type, graphicsLib_gSurface* surface, const st_float_position &pos, st_position adjust_pos, unsigned int frame_time, unsigned int repeat_times, int direction, st_size framesize);
void add_animation(animation anim);
void clear_animations(); // remove all animations from map
void set_player(classPlayer* player_ref);
classnpc *spawn_map_npc(short int npc_id, st_position npc_pos, short direction, bool player_friend, bool progressive_span);
int child_npc_count(int parent_id);
void move_npcs();
void show_npcs();
void show_npcs_to_left(int x);
void move_objects(bool paused);
void clean_finished_objects();
std::vector<object*> check_collision_with_objects(st_rectangle collision_area);
void show_objects(int adjust_y=0, int adjust_x=0);
void show_above_objects(int adjust_y=0, int adjust_x=0);
bool boss_hit_ground(classnpc *npc_ref);
classnpc* get_near_boss();
void reset_map_npcs();
void draw_dynamic_backgrounds_into_surface(graphicsLib_gSurface &surface);
void add_object(object obj);
st_position get_first_lock_in_direction(st_position pos, st_size max_dist, int direction);
int get_first_lock_on_left(int x_pos) const;
int get_first_lock_on_right(int x_pos) const;
int get_first_lock_on_bottom(int x_pos, int y_pos);
int get_first_lock_on_bottom(int x_pos, int y_pos, int w, int h);
void drop_item(classnpc *npc_ref);
void set_bg_scroll(int scrollx);
int get_bg_scroll() const;
void reset_map_timers();
void reset_enemies_timers();
void reset_objects_timers();
void reset_objects_anim_timers();
void reset_objects(); // restore objects to their original position
void print_objects_number();
void add_bubble_animation(st_position pos);
bool have_player_object();
bool subboss_alive_on_left(short tileX);
void finish_object_teleporter(int number);
void activate_final_boss_teleporter();
Uint8 get_map_gfx();
Uint8 get_map_gfx_mode();
st_float_position get_bg_scroll();
void set_bg_scroll(st_float_position pos);
st_rectangle get_player_hitbox();
st_float_position get_foreground_postion();
void set_foreground_postion(st_float_position pos);
bool must_show_static_bg(); // method used to prevent showing enemies on transition if showing static-bg
private:
void load_map_npcs();
void draw_dynamic_backgrounds();
void draw_static_background();
void draw_foreground_layer(int scroll_x, int scroll_y);
void adjust_dynamic_background_position();
void adjust_foreground_position();
bool value_in_range(int value, int min, int max) const;
void create_dynamic_background_surfaces();
graphicsLib_gSurface* get_dynamic_bg();
graphicsLib_gSurface* get_dynamic_foreground();
void set_map_enemy_static_background(std::string filename, st_position pos);
public:
std::vector<classnpc> _npc_list; // vector npcs
std::vector<classnpc> _npc_spawn_list; // list of enemyes to be spawned, after added into _npc_list
classPlayer* _player_ref; // vector players
std::vector<animation> animation_list;
// vector teleporters
// vector objects
int number;
private:
int stage_number;
struct st_float_position scroll;
st_float_position scrolled; // stores the value the map scrolled in this cycle. used for character movement control (it should move taking the scroll in account)
bool wall_scroll_lock[MAP_W];
st_float_position bg_scroll;
st_float_position fg_layer_scroll;
graphicsLib_gSurface static_bg;
st_position static_bg_pos;
short _platform_leave_counter;
water_bubble _water_bubble;
st_rectangle _3rd_level_ignore_area;
object_collision _obj_collision;
std::vector<st_level3_tile> _level3_tiles;
std::vector<object> object_list;
// DRAW MEMBERS //
int _show_map_pos_x; // this is used to compare the position that the map was drawn last time to the current scrolling to check if map needs to be redrawn
graphicsLib_gSurface map_screen; // use to avoid having to draw the tilesets each time we update screen
std::vector<anim_tile_desc> anim_tile_list; // list of animated tiles, so we don't need to loop through all tiles when drawing only the animated ones
};
#endif // CLASSMAP_H