Added DSP routines.
[cantaveria.git] / game.h
blob38de666b8e15bd3de6e27963a8ec6560c6dc039a
1 /*
2 Cantaveria - action adventure platform game
3 Copyright (C) 2009 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
24 #define PIXUP 1024
26 struct screen {
27 unsigned char tiles[20][15];
28 int flags;
29 int exits[4];
32 typedef struct {
33 char* name;
34 struct screen** screens;
35 int tileset_gfx;
36 char tileset_shapes[256];
37 /*background*/
38 int x,y,w,h;
40 int bg_gfx;
41 } zone;
43 #define ZONE_LOOKUP(Z,I,J) (I >= Z->w || J >= Z->h || I < 0 || J < 0 ? NULL : *(Z->screens + (I) + (J)*Z->w))
45 struct box{int x,y,w,h;};
47 typedef struct {
48 struct box box; /*absolute coords*/
49 int x, y; /*absolute coords*/
50 int vx, vy; /* pixels per ms / 256 */
51 int xoff, yoff; /* pixel coords*/
52 int bxoff, byoff; /* absolute coords */
53 enum {LEFT, RIGHT} facing;
54 sprite* spr; /*pixel coords*/
55 zone* z;
56 int si, sj;
57 int flags;
58 } mobile;
60 typedef struct {
61 struct box box;
62 int type;
63 } bullet;
65 typedef struct {
66 struct box box;
67 //sprite* spr;
68 int params[6];
69 int t;
70 } moveplat;
73 struct player_motion {
74 int state;
75 int timer;
80 struct game {
81 void (*update)();
82 void (*draw)();
84 rng_state rng;
86 zone* zones[32];
87 int zone_count;
89 /*these track the location of the player*/
90 int player_x;
91 int player_y;
92 zone* current_zone;
93 int si, sj;
96 /* entities */
100 extern struct game game;
102 enum {
103 SPRITE_ONE,
104 SPRITE_TWO,
105 SPRITE_THREE,
106 SPRITE_FOUR,
107 SPR_BOX
111 void load_zone(char* filename);
114 int stage_collision(mobile* m, zone* z, int si, int sj);
115 int box_collision(struct box* B1, struct box* B2);
117 void update_mobile_motion(mobile* m);
120 void game_setup();