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 |
---|
40 | class game; |
---|
41 | extern game *the_game; |
---|
42 | extern window_manager *eh; |
---|
43 | extern int dev; |
---|
44 | extern int morph_sel_frame_color; |
---|
45 | |
---|
46 | extern char **start_argv; |
---|
47 | extern int start_argc; |
---|
48 | extern long current_vxadd,current_vyadd; |
---|
49 | extern int frame_panic,massive_frame_panic; |
---|
50 | extern int demo_start,idle_ticks; |
---|
51 | |
---|
52 | class game |
---|
53 | { |
---|
54 | JCFont *fnt; |
---|
55 | int finished; |
---|
56 | int bg_top,fg_top; // in the fg/bg window which tile is at the top? |
---|
57 | int bright_color,med_color,dark_color, // for boundaries and windows, etc |
---|
58 | morph_bright_color,morph_med_color,morph_dark_color; |
---|
59 | |
---|
60 | long last_time,fps; |
---|
61 | char mapname[100],command[200],help_text[200]; |
---|
62 | int refresh,mousex,mousey,help_text_frames; |
---|
63 | int has_joystick,no_delay; |
---|
64 | |
---|
65 | |
---|
66 | jwindow *top_menu,*joy_win,*last_input; |
---|
67 | JCFont *game_font; |
---|
68 | uchar keymap[512/8]; |
---|
69 | |
---|
70 | public : |
---|
71 | int key_down(int key) { return keymap[key/8]&(1<<(key%8)); } |
---|
72 | void set_key_down(int key, int x) { if (x) keymap[key/8]|=(1<<(key%8)); else keymap[key/8]&=~(1<<(key%8)); } |
---|
73 | void reset_keymap() { memset(keymap,0,sizeof(keymap)); } |
---|
74 | |
---|
75 | int nplayers; |
---|
76 | view *first_view,*old_view; |
---|
77 | int state,zoom; |
---|
78 | |
---|
79 | |
---|
80 | game(int argc, char **argv); |
---|
81 | void step(); |
---|
82 | void show_help(char *st); |
---|
83 | void draw_value(image *screen, int x, int y, int w, int h, int val, int max); |
---|
84 | unsigned char get_color(int x) { return x; } |
---|
85 | int done(); |
---|
86 | void draw(int scene_mode=0); |
---|
87 | |
---|
88 | backtile *get_bg(int x) { if (x<0 || x>=nbacktiles || backtiles[x]<0) |
---|
89 | return cash.backt(backtiles[BLACK]); |
---|
90 | else return cash.backt(backtiles[x]); } |
---|
91 | foretile *get_fg(int x) { if (x<0 || x>=nforetiles || foretiles[x]<0) |
---|
92 | return cash.foret(foretiles[BLACK]); else |
---|
93 | return cash.foret(foretiles[x]); } |
---|
94 | |
---|
95 | void ftile_on(int screenx, int screeny, long &x, long &y); |
---|
96 | void btile_on(int screenx, int screeny, long &x, long &y); |
---|
97 | void toggle_delay(); |
---|
98 | void set_delay(int on) { no_delay=!on; } |
---|
99 | void pan(int xv, int yv); |
---|
100 | |
---|
101 | void mouse_to_game(long x, long y, long &gamex, long &gamey, view *v=NULL); |
---|
102 | void game_to_mouse(long gamex, long gamey, view *which, long &x, long &y); |
---|
103 | view *view_in(int mousex, int mousey); |
---|
104 | |
---|
105 | int calc_speed(); |
---|
106 | int ftile_width() { return f_wid; } |
---|
107 | int ftile_height() { return f_hi; } |
---|
108 | |
---|
109 | int btile_width() { return b_wid; } |
---|
110 | int btile_height() { return b_hi; } |
---|
111 | |
---|
112 | |
---|
113 | void put_fg(int x, int y, int type); |
---|
114 | void put_bg(int x, int y, int type); |
---|
115 | void draw_map(view *v, int interpolate=0); |
---|
116 | void dev_scroll(); |
---|
117 | void put_block_fg(int x, int y, trans_image *im); |
---|
118 | void put_block_bg(int x, int y, image *im); |
---|
119 | |
---|
120 | |
---|
121 | int in_area(event &ev, int x1, int y1, int x2, int y2); |
---|
122 | void load_level(char *name); |
---|
123 | void set_level(level *nl); |
---|
124 | void show_time(); |
---|
125 | tile_type get_map_bg(int x, int y) { return current_level->get_bg(x,y); } |
---|
126 | tile_type get_map_fg(int x, int y) { return current_level->get_fg(x,y); } |
---|
127 | void end_session(); |
---|
128 | void need_refresh() { refresh=1; } // for development mode only |
---|
129 | palette *current_palette() { return pal; } |
---|
130 | |
---|
131 | void update_screen(); |
---|
132 | void get_input(); |
---|
133 | void do_intro(); |
---|
134 | void joy_calb(event &ev); |
---|
135 | void menu_select(event &ev2); |
---|
136 | int can_morph_into(int type); |
---|
137 | void morph_into(int type); |
---|
138 | void set_state(int new_state); |
---|
139 | int game_over(); |
---|
140 | void grow_views(int amount); |
---|
141 | void play_sound(int id, int vol, long x, long y); |
---|
142 | void request_level_load(char *name); |
---|
143 | void request_end(); |
---|
144 | ~game(); |
---|
145 | } ; |
---|
146 | |
---|
147 | extern int playing_state(int state); |
---|
148 | #endif |
---|
149 | |
---|
150 | |
---|