| 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 | Uint8 ship; |
| 40 | Uint8 generator; |
| 41 | Uint8 shield; |
| 42 | struct |
| 43 | { |
| 44 | Uint8 id; |
| 45 | Uint8 power; |
| 46 | } weapon[2]; |
| 47 | Uint8 sidekick[2]; |
| 48 | Uint8 special; |
| 49 | |
| 50 | // Dragonwing only: |
| 51 | // repeatedly collecting the same powerup gives a series of sidekick upgrades |
| 52 | Uint8 sidekick_series; |
| 53 | Uint8 sidekick_level; |
| 54 | |
| 55 | // Single-player only |
| 56 | Uint8 super_arcade_mode; // stored as an item for compatibility :( |
| 57 | } |
| 58 | PlayerItems; |
| 59 | |
| 60 | typedef struct |
| 61 | { |
| 62 | ulong cash; |
| 63 | |
| 64 | PlayerItems items, last_items; |
| 65 | |
| 66 | bool is_dragonwing; // i.e., is player 2 |
| 67 | Uint8 *lives; |
| 68 | |
| 69 | // calculatable |
| 70 | uint shield_max; |
| 71 | uint initial_armor; |
| 72 | uint shot_hit_area_x, shot_hit_area_y; |
| 73 | |
| 74 | // state |
| 75 | bool is_alive; |
| 76 | uint invulnerable_ticks; // ticks until ship can be damaged |
| 77 | uint exploding_ticks; // ticks until ship done exploding |
| 78 | uint shield; |
| 79 | uint armor; |
| 80 | uint weapon_mode; |
| 81 | uint superbombs; |
| 82 | uint purple_balls_needed; |
| 83 | |
| 84 | int x, y; |
| 85 | int old_x[20], old_y[20]; |
| 86 | |
| 87 | int x_velocity, y_velocity; |
| 88 | uint x_friction_ticks, y_friction_ticks; // ticks until friction is applied |
| 89 | |
| 90 | int delta_x_shot_move, delta_y_shot_move; |
| 91 | |
| 92 | int last_x_shot_move, last_y_shot_move; |
| 93 | int last_x_explosion_follow, last_y_explosion_follow; |
| 94 | |
| 95 | struct |
| 96 | { |
| 97 | // calculatable |
| 98 | int ammo_max; |
| 99 | uint ammo_refill_ticks_max; |
| 100 | uint style; // affects movement and size |
| 101 | |
| 102 | // state |
| 103 | int x, y; |
| 104 | int ammo; |
| 105 | uint ammo_refill_ticks; |
| 106 | |
| 107 | bool animation_enabled; |
| 108 | uint animation_frame; |
| 109 | |
| 110 | uint charge; |
| 111 | uint charge_ticks; |
| 112 | } |
| 113 | sidekick[2]; |
| 114 | } |
| 115 | Player; |
| 116 | |
| 117 | extern Player player[2]; |
| 118 | |
| 119 | static inline bool all_players_dead(void) |
| 120 | { |
| 121 | return (!player[0].is_alive && (!twoPlayerMode || !player[1].is_alive)); |
| 122 | } |
| 123 | |
| 124 | static inline bool all_players_alive(void) |
| 125 | { |
| 126 | return (player[0].is_alive && (!twoPlayerMode || player[1].is_alive)); |
| 127 | } |
| 128 | |
| 129 | void calc_purple_balls_needed(Player *); |
| 130 | bool power_up_weapon(Player *, uint port); |
| 131 | void handle_got_purple_ball(Player *); |
| 132 | |
| 133 | #endif // PLAYER_H |