Many changes. Stage collision algorithm.
[cantaveria.git] / game.h
blob76354564a465f8910340fea437401655d6b6bb75
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;
39 } zone;
41 #define ZONE_LOOKUP(Z,I,J) (I >= Z->w || J >= Z->h || I < 0 || J < 0 ? NULL : *(Z->screens + I + J*Z->w))
43 struct box{int x,y,w,h;};
45 typedef struct {
46 struct box box; /*absolute coords*/
47 int x, y; /*absolute coords*/
48 int vx, vy; /* pixels per ms / 256 */
49 int xoff, yoff; /* pixel coords*/
50 int bxoff, byoff; /* absolute coords */
51 sprite* spr; /*pixel coords*/
52 int flags;
53 } mobile;
55 typedef struct {
56 struct box box;
57 int type;
58 } bullet;
60 typedef struct {
61 struct box box;
62 //sprite* spr;
63 int params[6];
64 int t;
65 } moveplat;
68 struct player_motion {
69 int state;
70 int timer;
75 struct game {
76 void (*update)();
77 void (*draw)();
79 rng_state rng;
81 zone* zones[32];
82 int zone_count;
84 /*these track the location of the player*/
85 int player_x;
86 int player_y;
87 zone* current_zone;
88 int si, sj;
91 /* entities */
95 extern struct game game;
97 enum {
98 SPRITE_ONE,
99 SPRITE_TWO,
100 SPRITE_THREE,
101 SPRITE_FOUR,
102 SPR_BOX
106 void load_game();
108 void load_zone(char* filename);
111 int stage_collision(mobile* m, zone* z, int si, int sj);
112 int box_collision(struct box* B1, struct box* B2);
114 void update_mobile_motion(mobile* m);