source: abuse/trunk/src/include/game.hpp @ 43

Last change on this file since 43 was 39, checked in by Sam Hocevar, 14 years ago
  • Fix almost 2,000 warnings by using proper "const" keywords where needed.
File size: 4.2 KB
Line 
1#ifndef __GAME_HPP_
2#define __GAME_HPP_
3
4#include "loader2.hpp"
5
6#include "macs.hpp"
7#include "image.hpp"
8#include "video.hpp"
9#include "mdlread.hpp"
10#include "event.hpp"
11#include "fonts.hpp"
12#include "loader.hpp"
13#include "monoprnt.hpp"
14#include "items.hpp"
15#include "jwindow.hpp"
16#include "filter.hpp"
17#include "level.hpp"
18#include "cache.hpp"
19#include "director.hpp"
20#include "view.hpp"
21#include "id.hpp"
22
23#define MAPFW                           100
24#define MAPFH                           100
25#define MAPBW                           100
26#define MAPBH                           100
27
28#define RUN_STATE 0
29#define PAUSE_STATE 1
30#define HELP_STATE 2
31#define INTRO_START_STATE 3
32#define INTRO_MORPH_STATE 4
33#define JOY_CALB_STATE    5
34#define MENU_STATE        6
35#define SCENE_STATE       7
36#define START_STATE       8
37#define BLACK 0
38
39#define tile_type unsigned short
40class game;
41extern game *the_game;
42extern window_manager *eh;
43extern int dev;
44extern int morph_sel_frame_color;
45
46extern char **start_argv;
47extern int start_argc;
48extern int32_t current_vxadd,current_vyadd;
49extern int frame_panic,massive_frame_panic;
50extern int demo_start,idle_ticks;
51
52extern FILE *open_FILE(char const *filename, char const *mode);
53
54class game
55{
56  JCFont *fnt;
57  int finished;
58  int bg_top,fg_top;                         // in the fg/bg window which tile is at the top?
59  int bright_color,med_color,dark_color,     // for boundaries and windows, etc
60      morph_bright_color,morph_med_color,morph_dark_color;
61
62  int32_t last_time,fps;
63  char mapname[100],command[200],help_text[200];
64  int refresh,mousex,mousey,help_text_frames;
65  int has_joystick,no_delay;
66
67
68  jwindow *top_menu,*joy_win,*last_input;
69  JCFont *game_font;
70  uint8_t keymap[512/8];
71
72public :
73  int key_down(int key) { return keymap[key/8]&(1<<(key%8)); }
74  void set_key_down(int key, int x) { if (x) keymap[key/8]|=(1<<(key%8)); else keymap[key/8]&=~(1<<(key%8)); }
75  void reset_keymap() { memset(keymap,0,sizeof(keymap)); }
76
77  int nplayers;
78  view *first_view,*old_view;
79  int state,zoom;
80
81
82  game(int argc, char **argv);
83  void step();
84  void show_help(char const *st);
85  void draw_value(image *screen, int x, int y, int w, int h, int val, int max);
86  unsigned char get_color(int x) { return x; }
87  int done();
88  void draw(int scene_mode=0);
89
90  backtile *get_bg(int x) { if (x<0 || x>=nbacktiles || backtiles[x]<0)
91                           return cash.backt(backtiles[BLACK]);
92                           else return cash.backt(backtiles[x]); }
93  foretile *get_fg(int x) { if (x<0 || x>=nforetiles || foretiles[x]<0)
94                           return cash.foret(foretiles[BLACK]); else
95                           return cash.foret(foretiles[x]); }
96
97  void ftile_on(int screenx, int screeny, int32_t &x, int32_t &y);
98  void btile_on(int screenx, int screeny, int32_t &x, int32_t &y);
99  void toggle_delay();
100  void set_delay(int on) { no_delay=!on; }
101  void pan(int xv, int yv);
102
103  void mouse_to_game(int32_t x, int32_t y, int32_t &gamex, int32_t &gamey, view *v=NULL);
104  void game_to_mouse(int32_t gamex, int32_t gamey, view *which, int32_t &x, int32_t &y);
105  view *view_in(int mousex, int mousey);
106
107  int calc_speed();
108  int ftile_width()  { return f_wid; }
109  int ftile_height() { return f_hi; }
110
111  int btile_width()  { return b_wid; }
112  int btile_height() { return b_hi; }
113
114
115  void put_fg(int x, int y, int type);
116  void put_bg(int x, int y, int type);
117  void draw_map(view *v, int interpolate=0);
118  void dev_scroll();
119  void put_block_fg(int x, int y, trans_image *im);
120  void put_block_bg(int x, int y, image *im);
121
122
123  int in_area(event &ev, int x1, int y1, int x2, int y2);
124  void load_level(char const *name);
125  void set_level(level *nl);
126  void show_time();
127  tile_type get_map_bg(int x, int y) { return current_level->get_bg(x,y); }
128  tile_type get_map_fg(int x, int y) { return current_level->get_fg(x,y); }
129  void end_session();
130  void need_refresh() { refresh=1; }       // for development mode only
131  palette *current_palette() { return pal; }
132
133  void update_screen();
134  void get_input();
135  void do_intro();
136  void joy_calb(event &ev);
137  void menu_select(event &ev2);
138  int can_morph_into(int type);
139  void morph_into(int type);
140  void set_state(int new_state);
141  int game_over();
142  void grow_views(int amount);
143  void play_sound(int id, int vol, int32_t x, int32_t y);
144  void request_level_load(char *name);
145  void request_end();
146  ~game();
147} ;
148
149extern int playing_state(int state);
150#endif
151
152
Note: See TracBrowser for help on using the repository browser.