source: ttyvaders/trunk/src/common.h @ 1057

Last change on this file since 1057 was 1057, checked in by Sam Hocevar, 14 years ago
  • Bring the tree back in sync with the new libcaca API.
  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1/*
2 *   ttyvaders     Textmode shoot'em up
3 *   Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
4 *                 All Rights Reserved
5 *
6 *   $Id: common.h 1057 2006-09-18 16:54:08Z sam $
7 *
8 *   This program is free software; you can redistribute it and/or modify
9 *   it under the terms of the GNU General Public License as published by
10 *   the Free Software Foundation; either version 2 of the License, or
11 *   (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23/*
24 * Compile-time limits
25 */
26#define STARS 50
27#define WEAPONS 200
28#define BONUS 30
29#define ALIENS 30
30#define EXPLOSIONS 200
31
32/*
33 * Game defines
34 */
35#define MAX_LIFE 1000
36#define MAX_SPECIAL 200
37
38#define COST_NUKE     (100*MAX_SPECIAL/100)
39#define COST_BEAM      (75*MAX_SPECIAL/100)
40#define COST_FRAGBOMB  (50*MAX_SPECIAL/100)
41
42/*
43 * Graphics primitives
44 */
45#include <caca.h>
46
47/*
48 * Useful macros
49 */
50#define GET_MAX(a,b) ((a)>(b)?(a):(b))
51#define GET_MIN(a,b) ((a)<(b)?(a):(b))
52
53/*
54 * Game structures
55 */
56typedef struct
57{
58    int w, h, *left, *right;
59
60} tunnel;
61
62typedef struct
63{
64    int x, y, z, c;
65    char ch;
66
67} starfield;
68
69typedef struct
70{
71    enum { EXPLOSION_NONE, EXPLOSION_SMALL, EXPLOSION_MEDIUM } type[EXPLOSIONS];
72    int x[EXPLOSIONS];
73    int y[EXPLOSIONS];
74    int vx[EXPLOSIONS];
75    int vy[EXPLOSIONS];
76    int n[EXPLOSIONS];
77
78} explosions;
79
80typedef struct
81{
82    enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM, WEAPON_LIGHTNING, WEAPON_BOMB, WEAPON_FRAGBOMB } type[WEAPONS];
83    int x[WEAPONS];
84    int y[WEAPONS];
85    int x2[WEAPONS];
86    int y2[WEAPONS];
87    int x3[WEAPONS];
88    int y3[WEAPONS];
89    int vx[WEAPONS];
90    int vy[WEAPONS];
91    int n[WEAPONS];
92
93} weapons;
94
95typedef struct
96{
97    enum { BONUS_NONE, BONUS_LIFE, BONUS_GREEN } type[BONUS];
98    int x[BONUS];
99    int y[BONUS];
100    int n[BONUS];
101
102} bonus;
103
104typedef struct
105{
106    int x, y;
107    int vx, vy;
108    int weapon, special;
109    int life, dead;
110
111} player;
112
113typedef struct
114{
115    enum { ALIEN_NONE, ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ } type[ALIENS];
116    int x[ALIENS];
117    int y[ALIENS];
118    int life[ALIENS];
119    int img[ALIENS];
120
121} aliens;
122
123typedef struct
124{
125    int w, h;
126    int x, y;
127    int frame;
128
129} box;
130
131typedef struct
132{
133    int w, h;
134
135    cucul_canvas_t *cv;
136    caca_display_t *dp;
137
138    starfield *sf;
139    weapons *wp;
140    explosions *ex;
141    tunnel *t;
142    player *p;
143    aliens *al;
144    bonus *bo;
145
146} game;
147
148void intro(game *g);
149
150/*
151 * From aliens.c
152 */
153void init_aliens(game *, aliens *);
154void draw_aliens(game *, aliens *);
155void update_aliens(game *, aliens *);
156void add_alien(game *, aliens *, int, int, int);
157
158/*
159 * From bonus.c
160 */
161void init_bonus(game *, bonus *);
162void draw_bonus(game *, bonus *);
163void update_bonus(game *, bonus *);
164void add_bonus(game *, bonus *, int, int, int);
165
166/*
167 * From box.c
168 */
169box * create_box(game *, int, int, int, int);
170void draw_box(game *, box *);
171void free_box(box *);
172
173/*
174 * From ceo.c
175 */
176void ceo_alert(game *);
177
178/*
179 * From collide.c
180 */
181void collide_weapons_tunnel(game *, weapons *, tunnel *, explosions *);
182void collide_weapons_aliens(game *, weapons *, aliens *, explosions *);
183void collide_player_tunnel(game *, player *, tunnel *, explosions *);
184
185/*
186 * From explosions.c
187 */
188void init_explosions(game *, explosions *);
189void add_explosion(game *, explosions *, int, int, int, int, int);
190void draw_explosions(game *, explosions *);
191void update_explosions(game *, explosions *);
192
193/*
194 * From overlay.c
195 */
196void draw_status(game *);
197
198/*
199 * From player.c
200 */
201player * create_player(game *);
202void free_player(player *);
203void draw_player(game *, player *);
204void update_player(game *, player *);
205
206/*
207 * From starfield.c
208 */
209starfield * create_starfield(game *);
210void draw_starfield(game *, starfield *);
211void update_starfield(game *, starfield *);
212void free_starfield(game *, starfield *);
213
214/*
215 * From tunnel.c
216 */
217tunnel * create_tunnel(game *, int, int);
218void free_tunnel(tunnel *);
219void draw_tunnel(game *, tunnel *);
220void update_tunnel(game *, tunnel *);
221
222/*
223 * From weapons.c
224 */
225void init_weapons(game *, weapons *);
226void draw_weapons(game *, weapons *);
227void update_weapons(game *, weapons *);
228void add_weapon(game *, weapons *, int, int, int, int, int);
229
Note: See TracBrowser for help on using the repository browser.