source: abuse/trunk/src/game.h @ 555

Last change on this file since 555 was 555, checked in by Sam Hocevar, 11 years ago

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

  • Property svn:keywords set to Id
File size: 4.6 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[2]11#ifndef __GAME_HPP_
12#define __GAME_HPP_
13
[481]14#include "loader2.h"
[2]15
[481]16#include "image.h"
17#include "video.h"
18#include "event.h"
19#include "fonts.h"
20#include "items.h"
21#include "jwindow.h"
22#include "filter.h"
23#include "level.h"
24#include "cache.h"
25#include "director.h"
26#include "view.h"
27#include "id.h"
[2]28
[124]29#define MAPFW                100
30#define MAPFH                100
31#define MAPBW                100
32#define MAPBH                100
[2]33
34#define RUN_STATE 0
35#define PAUSE_STATE 1
36#define HELP_STATE 2
37#define INTRO_START_STATE 3
38#define INTRO_MORPH_STATE 4
39#define JOY_CALB_STATE    5
40#define MENU_STATE        6
41#define SCENE_STATE       7
42#define START_STATE       8
43#define BLACK 0
44
[88]45/* Cleaned-up externs */
[120]46extern WindowManager *wm;
[88]47
48
[2]49#define tile_type unsigned short
[127]50class Game;
51extern Game *the_game;
[2]52extern int dev;
53extern int morph_sel_frame_color;
54
55extern char **start_argv;
56extern int start_argc;
[16]57extern int32_t current_vxadd,current_vyadd;
[2]58extern int frame_panic,massive_frame_panic;
59extern int demo_start,idle_ticks;
60
[39]61extern FILE *open_FILE(char const *filename, char const *mode);
62
[127]63class Game
[2]64{
[127]65private:
[2]66  JCFont *fnt;
[127]67  bool finished;
[2]68  int bg_top,fg_top;                         // in the fg/bg window which tile is at the top?
69  int bright_color,med_color,dark_color,     // for boundaries and windows, etc
70      morph_bright_color,morph_med_color,morph_dark_color;
71
[16]72  int32_t last_time,fps;
[2]73  char mapname[100],command[200],help_text[200];
74  int refresh,mousex,mousey,help_text_frames;
75  int has_joystick,no_delay;
76
77
[120]78  Jwindow *top_menu,*joy_win,*last_input;
[2]79  JCFont *game_font;
[17]80  uint8_t keymap[512/8];
[2]81
[124]82public :
[2]83  int key_down(int key) { return keymap[key/8]&(1<<(key%8)); }
84  void set_key_down(int key, int x) { if (x) keymap[key/8]|=(1<<(key%8)); else keymap[key/8]&=~(1<<(key%8)); }
85  void reset_keymap() { memset(keymap,0,sizeof(keymap)); }
86
87  int nplayers;
88  view *first_view,*old_view;
89  int state,zoom;
90
[127]91  Game(int argc, char **argv);
92  ~Game();
[2]93
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
[124]101  backtile *get_bg(int x) { if (x<0 || x>=nbacktiles || backtiles[x]<0)
102                           return cache.backt(backtiles[BLACK]);
[123]103                           else return cache.backt(backtiles[x]); }
[124]104  foretile *get_fg(int x) { if (x<0 || x>=nforetiles || foretiles[x]<0)
105                           return cache.foret(foretiles[BLACK]); else
106               return cache.foret(foretiles[x]); }
[2]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();
[541]130  void put_block_fg(int x, int y, TransImage *im);
[2]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} ;
158
159extern int playing_state(int state);
160#endif
161
162
Note: See TracBrowser for help on using the repository browser.