source: abuse/trunk/src/game.hpp @ 66

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