Roguelike
 All Classes Namespaces Functions Variables Typedefs Friends Pages
game.h
1 
20 #ifndef _CANVAS_H
21 #define _CANVAS_H
22 
23 #include <stdlib.h>
24 #include <vector>
25 #include <assert.h>
26 
27 #include <chunk.h>
28 #include <chunk_matrix.h>
29 #include <constants.h>
30 #include <bresenham.h>
31 #include <enemy.h>
32 #include <defs.h>
33 #include <character.h>
34 #include <world_map.h>
35 #include <helper.h>
36 #include <item.h>
37 #include <animation.h>
38 #include <animation_defs.h>
39 
47 namespace td=tiledef;
48 
49 class Game
50 {
51  typedef std::vector<std::vector<Tile> > TileMatrix;
52  typedef std::vector<std::vector<Tile*> > TilePointerMatrix;
53  typedef std::vector<std::vector<MapTile> > MapTileMatrix;
54 
55  private:
56 
57  //BASE Data/Models
62 
68  bool paused;
69 
74  MapTileMatrix world_map;
75 
84 
88  Tile tile_index[td::TILE_TYPE_COUNT];
89 
94  std::vector<Animation> anim_queue;
95 
96  //BASE model access functions
102  void point_assertions(int row, int col);
103 
104 
111  void set_tile(int row, int col, Tile* tile);
112 
118  void set_tile(IntPoint point, Tile* tile);
119 
127 
131  Tile* get_tile(int row, int col);
132 
136  Tile* get_tile(IntPoint point);
137 
141  bool out_of_bounds(IntPoint point);
142 
146  bool out_of_bounds(int row, int col);
147 
151  bool in_buffer(int row, int col);
152 
162  bool in_range(IntPoint chunk, IntPoint coords, IntPoint range_chunk, IntPoint center, IntPoint radius);
163 
167  void update_main_char_chunk();
168  IntPoint get_canvas_coords(IntPoint, IntPoint);
169  IntPoint get_buffer_coords(IntPoint, IntPoint);
170  Character* enemy_at_loc(IntPoint, IntPoint);
171 
172  //RENDERING Data/Models
173  TilePointerMatrix canvas;
174  TilePointerMatrix buffer;
175  std::vector<std::vector<IntPoint> > bresenham_lines;
176 
177 
178  //ENEMY Data/Models
179  std::vector<Enemy*> enemy_list;
180 
181  //ENEMY Functionality
182 
183 public:
184  Game();
185  ~Game();
186  void init(const MapTileMatrix&, IntPoint);
187 
188  //BASE Data/Models
189  Main_Character main_char;
190 
191  //BASE Model access
192  Chunk* get_current_chunk();
193  bool is_initialized();
194  void act(long);
195  bool is_paused();
196  void pause();
197  void unpause();
198  void toggle_pause();
199  //RENDERING Functionality
200  const std::vector<std::vector<Tile*> >& get_canvas();
201  IntPoint get_vis_coords(IntPoint, IntPoint);
202  std::vector<Enemy*> get_vis_enemies();
203  void show_vis_items();
204  std::vector<Animation>& get_animations();
205  void tick_animations(long delta_ms);
206  bool is_vis(IntPoint coords);
207  void refresh();
208  void recalculate_visibility_lines(int radius);
209  void update_buffer(IntPoint);
210  void update_chunk_map(IntPoint);
211  void draw_visibility_lines();
212  void undo_visibility();
213 
214  //ENEMY Functionality
215  void run_spawners();
216  void run_enemies(long);
217  void remove_targets(Character* enem);
218  std::vector<Enemy*>& get_enemies();
219  //MAIN CHAR Functionality
220  void change_depth(int, Character*);
221  void move_char(int, int, Character*) ;
222  void get_item(Character*);
223  void drop_item(Item*, Character*);
224 
225  //DEBUG FUNCTIONS
226  void spawn_enemy(int, int, int, int, int, int);
227 
231  void teleport(int chunk_x, int chunk_y, int x, int y);
232 
233  //ANIMATION FUNCTIONS
234  void create_explosion(int x, int y, int chunk_x, int chunk_y);
235 };
236 
237 #endif
MapTileMatrix world_map
Definition: game.h:74
void get_item(Character *)
Definition: game.cpp:398
void update_main_char_chunk()
void point_assertions(int row, int col)
Definition: game.cpp:422
Definition: character.h:42
bool in_buffer(int row, int col)
Definition: game.cpp:498
bool paused
Definition: game.h:68
Definition: chunk.h:98
bool out_of_bounds(IntPoint point)
Definition: game.cpp:462
Definition: game.h:49
void run_enemies(long)
Definition: game.cpp:256
Definition: character.h:551
Definition: defs.h:66
Definition: item.h:40
Definition: int_point.h:26
void teleport(int chunk_x, int chunk_y, int x, int y)
Definition: game.cpp:723
void update_buffer(IntPoint)
Definition: game.cpp:602
void set_tile(int row, int col, Tile *tile)
Definition: game.cpp:429
ChunkMatrix chunk_map
Definition: game.h:83
Tile tile_index[td::TILE_TYPE_COUNT]
Definition: game.h:88
std::vector< Animation > anim_queue
Definition: game.h:94
bool in_range(IntPoint chunk, IntPoint coords, IntPoint range_chunk, IntPoint center, IntPoint radius)
Definition: game.cpp:502
Tile * get_tile(int row, int col)
Definition: game.cpp:452
void recalculate_visibility_lines(int radius)
Definition: game.cpp:579
Definition: defs.cpp:30
bool initialized
Definition: game.h:61
Definition: chunk_matrix.h:51
Item * item_at_coords(IntPoint, IntPoint, int)
Definition: game.cpp:439