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

Last change on this file since 112 was 106, checked in by Sam Hocevar, 11 years ago
  • Rename the "eh" variable to "wm" because it's a window manager, not an event handler.
  • No longer pass the window manager to functions, there's only one.

Inspired by Win32 Abuse changelog for January 28, 2001:

  • Starting work on singleton code; will get rid of all

references to an arbitrary window_manager* because
there's only going to be one, and it's not ever
going to change.

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