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