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
RevLine 
[36]1/*
2 *   ttyvaders     Textmode shoot'em up
3 *   Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
4 *                 All Rights Reserved
5 *
[76]6 *   $Id: common.h 1057 2006-09-18 16:54:08Z sam $
[36]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 */
[18]22
[62]23/*
24 * Compile-time limits
25 */
[18]26#define STARS 50
[50]27#define WEAPONS 200
[20]28#define BONUS 30
29#define ALIENS 30
[50]30#define EXPLOSIONS 200
[18]31
[62]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 */
[1057]45#include <caca.h>
[18]46
[62]47/*
48 * Useful macros
49 */
[50]50#define GET_MAX(a,b) ((a)>(b)?(a):(b))
51#define GET_MIN(a,b) ((a)<(b)?(a):(b))
[18]52
[62]53/*
54 * Game structures
55 */
[18]56typedef struct
57{
58    int w, h, *left, *right;
59
60} tunnel;
61
62typedef struct
63{
[50]64    int x, y, z, c;
65    char ch;
[18]66
67} starfield;
68
69typedef struct
70{
[20]71    enum { EXPLOSION_NONE, EXPLOSION_SMALL, EXPLOSION_MEDIUM } type[EXPLOSIONS];
[18]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{
[42]82    enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM, WEAPON_LIGHTNING, WEAPON_BOMB, WEAPON_FRAGBOMB } type[WEAPONS];
[18]83    int x[WEAPONS];
84    int y[WEAPONS];
[20]85    int x2[WEAPONS];
86    int y2[WEAPONS];
87    int x3[WEAPONS];
88    int y3[WEAPONS];
89    int vx[WEAPONS];
90    int vy[WEAPONS];
[18]91    int n[WEAPONS];
92
93} weapons;
94
95typedef struct
96{
[20]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{
[18]106    int x, y;
[58]107    int vx, vy;
[62]108    int weapon, special;
[60]109    int life, dead;
[18]110
111} player;
112
113typedef struct
114{
[60]115    enum { ALIEN_NONE, ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ } type[ALIENS];
[18]116    int x[ALIENS];
117    int y[ALIENS];
118    int life[ALIENS];
119    int img[ALIENS];
120
121} aliens;
122
[20]123typedef struct
124{
125    int w, h;
[70]126    int x, y;
127    int frame;
[20]128
[70]129} box;
130
131typedef struct
132{
133    int w, h;
134
[1057]135    cucul_canvas_t *cv;
136    caca_display_t *dp;
[544]137
[20]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
[544]148void intro(game *g);
149
[62]150/*
151 * From aliens.c
152 */
[88]153void init_aliens(game *, aliens *);
154void draw_aliens(game *, aliens *);
155void update_aliens(game *, aliens *);
156void add_alien(game *, aliens *, int, int, int);
[18]157
[62]158/*
159 * From bonus.c
160 */
[88]161void init_bonus(game *, bonus *);
162void draw_bonus(game *, bonus *);
163void update_bonus(game *, bonus *);
164void add_bonus(game *, bonus *, int, int, int);
[62]165
166/*
[70]167 * From box.c
168 */
[88]169box * create_box(game *, int, int, int, int);
170void draw_box(game *, box *);
171void free_box(box *);
[70]172
173/*
[62]174 * From ceo.c
175 */
[88]176void ceo_alert(game *);
[62]177
178/*
179 * From collide.c
180 */
[88]181void collide_weapons_tunnel(game *, weapons *, tunnel *, explosions *);
182void collide_weapons_aliens(game *, weapons *, aliens *, explosions *);
183void collide_player_tunnel(game *, player *, tunnel *, explosions *);
[62]184
185/*
186 * From explosions.c
187 */
[88]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 *);
[62]192
193/*
194 * From overlay.c
195 */
[88]196void draw_status(game *);
[62]197
198/*
199 * From player.c
200 */
[88]201player * create_player(game *);
202void free_player(player *);
203void draw_player(game *, player *);
204void update_player(game *, player *);
[18]205
[62]206/*
207 * From starfield.c
208 */
[88]209starfield * create_starfield(game *);
210void draw_starfield(game *, starfield *);
211void update_starfield(game *, starfield *);
212void free_starfield(game *, starfield *);
[18]213
[62]214/*
215 * From tunnel.c
216 */
[88]217tunnel * create_tunnel(game *, int, int);
218void free_tunnel(tunnel *);
219void draw_tunnel(game *, tunnel *);
220void update_tunnel(game *, tunnel *);
[18]221
[62]222/*
223 * From weapons.c
224 */
[88]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);
[18]229
Note: See TracBrowser for help on using the repository browser.