Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

225 lignes
4.4 KiB

  1. /*
  2. * ttyvaders Textmode shoot'em up
  3. * Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  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. * Compile-time limits
  24. */
  25. #define STARS 50
  26. #define WEAPONS 200
  27. #define BONUS 30
  28. #define ALIENS 30
  29. #define EXPLOSIONS 200
  30. /*
  31. * Game defines
  32. */
  33. #define MAX_LIFE 1000
  34. #define MAX_SPECIAL 200
  35. #define COST_NUKE (100*MAX_SPECIAL/100)
  36. #define COST_BEAM (75*MAX_SPECIAL/100)
  37. #define COST_FRAGBOMB (50*MAX_SPECIAL/100)
  38. /*
  39. * Graphics primitives
  40. */
  41. #include "ee.h"
  42. /*
  43. * Useful macros
  44. */
  45. #define GET_MAX(a,b) ((a)>(b)?(a):(b))
  46. #define GET_MIN(a,b) ((a)<(b)?(a):(b))
  47. /*
  48. * Game structures
  49. */
  50. typedef struct
  51. {
  52. int w, h, *left, *right;
  53. } tunnel;
  54. typedef struct
  55. {
  56. int x, y, z, c;
  57. char ch;
  58. } starfield;
  59. typedef struct
  60. {
  61. enum { EXPLOSION_NONE, EXPLOSION_SMALL, EXPLOSION_MEDIUM } type[EXPLOSIONS];
  62. int x[EXPLOSIONS];
  63. int y[EXPLOSIONS];
  64. int vx[EXPLOSIONS];
  65. int vy[EXPLOSIONS];
  66. int n[EXPLOSIONS];
  67. } explosions;
  68. typedef struct
  69. {
  70. enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM, WEAPON_LIGHTNING, WEAPON_BOMB, WEAPON_FRAGBOMB } type[WEAPONS];
  71. int x[WEAPONS];
  72. int y[WEAPONS];
  73. int x2[WEAPONS];
  74. int y2[WEAPONS];
  75. int x3[WEAPONS];
  76. int y3[WEAPONS];
  77. int vx[WEAPONS];
  78. int vy[WEAPONS];
  79. int n[WEAPONS];
  80. } weapons;
  81. typedef struct
  82. {
  83. enum { BONUS_NONE, BONUS_LIFE, BONUS_GREEN } type[BONUS];
  84. int x[BONUS];
  85. int y[BONUS];
  86. int n[BONUS];
  87. } bonus;
  88. typedef struct
  89. {
  90. int x, y;
  91. int vx, vy;
  92. int weapon, special;
  93. int life, dead;
  94. } player;
  95. typedef struct
  96. {
  97. enum { ALIEN_NONE, ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ } type[ALIENS];
  98. int x[ALIENS];
  99. int y[ALIENS];
  100. int life[ALIENS];
  101. int img[ALIENS];
  102. } aliens;
  103. typedef struct
  104. {
  105. int w, h;
  106. int x, y;
  107. int frame;
  108. } box;
  109. typedef struct
  110. {
  111. int w, h;
  112. starfield *sf;
  113. weapons *wp;
  114. explosions *ex;
  115. tunnel *t;
  116. player *p;
  117. aliens *al;
  118. bonus *bo;
  119. } game;
  120. /*
  121. * From aliens.c
  122. */
  123. void init_aliens(game *, aliens *);
  124. void draw_aliens(game *, aliens *);
  125. void update_aliens(game *, aliens *);
  126. void add_alien(game *, aliens *, int, int, int);
  127. /*
  128. * From bonus.c
  129. */
  130. void init_bonus(game *, bonus *);
  131. void draw_bonus(game *, bonus *);
  132. void update_bonus(game *, bonus *);
  133. void add_bonus(game *, bonus *, int, int, int);
  134. /*
  135. * From box.c
  136. */
  137. box * create_box(game *, int, int, int, int);
  138. void draw_box(game *, box *);
  139. void free_box(box *);
  140. /*
  141. * From ceo.c
  142. */
  143. void ceo_alert(game *);
  144. /*
  145. * From collide.c
  146. */
  147. void collide_weapons_tunnel(game *, weapons *, tunnel *, explosions *);
  148. void collide_weapons_aliens(game *, weapons *, aliens *, explosions *);
  149. void collide_player_tunnel(game *, player *, tunnel *, explosions *);
  150. /*
  151. * From explosions.c
  152. */
  153. void init_explosions(game *, explosions *);
  154. void add_explosion(game *, explosions *, int, int, int, int, int);
  155. void draw_explosions(game *, explosions *);
  156. void update_explosions(game *, explosions *);
  157. /*
  158. * From overlay.c
  159. */
  160. void draw_status(game *);
  161. /*
  162. * From player.c
  163. */
  164. player * create_player(game *);
  165. void free_player(player *);
  166. void draw_player(game *, player *);
  167. void update_player(game *, player *);
  168. /*
  169. * From starfield.c
  170. */
  171. starfield * create_starfield(game *);
  172. void draw_starfield(game *, starfield *);
  173. void update_starfield(game *, starfield *);
  174. void free_starfield(game *, starfield *);
  175. /*
  176. * From tunnel.c
  177. */
  178. tunnel * create_tunnel(game *, int, int);
  179. void free_tunnel(tunnel *);
  180. void draw_tunnel(game *, tunnel *);
  181. void update_tunnel(game *, tunnel *);
  182. /*
  183. * From weapons.c
  184. */
  185. void init_weapons(game *, weapons *);
  186. void draw_weapons(game *, weapons *);
  187. void update_weapons(game *, weapons *);
  188. void add_weapon(game *, weapons *, int, int, int, int, int);