Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * OpenTyrian: A modern cross-platform port of Tyrian
  3.  * Copyright (C) 2007-2009  The OpenTyrian Development Team
  4.  *
  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.
  9.  *
  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.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  18.  */
  19. #ifndef PLAYER_H
  20. #define PLAYER_H
  21.  
  22. #include "config.h"
  23. #include "opentyr.h"
  24.  
  25. enum
  26. {
  27.         FRONT_WEAPON = 0,
  28.         REAR_WEAPON = 1
  29. };
  30.  
  31. enum
  32. {
  33.         LEFT_SIDEKICK = 0,
  34.         RIGHT_SIDEKICK = 1
  35. };
  36.  
  37. typedef struct
  38. {
  39.         uint ship;
  40.         uint generator;
  41.         uint shield;
  42.         struct { uint id; uint power; } weapon[2];
  43.         uint sidekick[2];
  44.         uint special;
  45.        
  46.         // Dragonwing only:
  47.         // repeatedly collecting the same powerup gives a series of sidekick upgrades
  48.         uint sidekick_series;
  49.         uint sidekick_level;
  50.        
  51.         // Single-player only
  52.         uint super_arcade_mode;  // stored as an item for compatibility :(
  53. }
  54. PlayerItems;
  55.  
  56. typedef struct
  57. {
  58.         ulong cash;
  59.        
  60.         PlayerItems items, last_items;
  61.        
  62.         bool is_dragonwing;  // i.e., is player 2
  63.         uint *lives;
  64.        
  65.         // calculatable
  66.         uint shield_max;
  67.         uint initial_armor;
  68.         uint shot_hit_area_x, shot_hit_area_y;
  69.        
  70.         // state
  71.         bool is_alive;
  72.         uint invulnerable_ticks;  // ticks until ship can be damaged
  73.         uint exploding_ticks;     // ticks until ship done exploding
  74.         uint shield;
  75.         uint armor;
  76.         uint weapon_mode;
  77.         uint superbombs;
  78.         uint purple_balls_needed;
  79.        
  80.         int x, y;
  81.         int old_x[20], old_y[20];
  82.        
  83.         int x_velocity, y_velocity;
  84.         uint x_friction_ticks, y_friction_ticks;  // ticks until friction is applied
  85.        
  86.         int delta_x_shot_move, delta_y_shot_move;
  87.        
  88.         int last_x_shot_move, last_y_shot_move;
  89.         int last_x_explosion_follow, last_y_explosion_follow;
  90.        
  91.         struct
  92.         {
  93.                 // calculatable
  94.                 int ammo_max;
  95.                 uint ammo_refill_ticks_max;
  96.                 uint style;  // affects movement and size
  97.                
  98.                 // state
  99.                 int x, y;
  100.                 int ammo;
  101.                 uint ammo_refill_ticks;
  102.                
  103.                 bool animation_enabled;
  104.                 uint animation_frame;
  105.                
  106.                 uint charge;
  107.                 uint charge_ticks;
  108.         }
  109.         sidekick[2];
  110. }
  111. Player;
  112.  
  113. extern Player player[2];
  114.  
  115. static inline bool all_players_dead( void )
  116. {
  117.         return (!player[0].is_alive && (!twoPlayerMode || !player[1].is_alive));
  118. }
  119.  
  120. static inline bool all_players_alive( void )
  121. {
  122.         return (player[0].is_alive && (!twoPlayerMode || player[1].is_alive));
  123. }
  124.  
  125. void calc_purple_balls_needed( Player * );
  126. bool power_up_weapon( Player *, uint port );
  127. void handle_got_purple_ball( Player * );
  128.  
  129. #endif // PLAYER_H
  130.