1
// $Id: pingu.hxx,v 1.24 2002/11/03 13:29:09 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 1999 Ingo Ruhnke <grumbel@gmx.de>
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 2
9
// of the License, or (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#ifndef HEADER_PINGUS_PINGU_HXX
21
#define HEADER_PINGUS_PINGU_HXX
23
#include "direction.hxx"
24
#include "pingu_enums.hxx"
26
// Forward declarations
32
/** The class for managing one of the many penguins which are walking
33
around in the World. All actions are handled by PinguAction
38
/** The primary action with is currently in use */
41
/** A secondary action which will turn active after a given amount of time
42
The only example is currently the bomber. */
43
PinguAction* countdown_action;
45
/** the action that gets triggered when the pingu hits a wall */
46
PinguAction* wall_action;
48
/** the action that gets triggered when the pingu falls */
49
PinguAction* fall_action;
51
/** The previous_action contains the action type that was in action
52
before action got applied, its here to enable action to behave
53
differently depending on the previous action */
54
Actions::ActionName previous_action;
56
/** The uniq id of the Pingu, this is used to refer to the Pingu in
57
a demo file or in a network connection */
63
/// The stat of the pingu, these can be modified by PinguActions
69
Vector* const velocity;
71
bool request_set_action (PinguAction*);
72
void set_action (PinguAction*);
76
//FIXME make me private
79
/** Creates a new Pingu at the given coordinates
80
@param arg_id The uniq id of the pingu
81
@param pos The start position of the pingu
82
@param owner The owner id of the pingu (used for multiplayer) */
83
Pingu (int arg_id, const Vector& pos, int owner);
85
/** Destruct the pingu... */
88
/** Return the logical pingus position, this is the position which
89
is used for collision detection to the ground (the pingus
91
Vector get_pos () const;
93
/** Returns the visible position of the pingu, the graphical center
95
Vector get_center_pos () const;
97
/** Returns the x position of the pingu
98
* For backward comp. only
100
const float& get_x () const { return pos_x; }
102
/** Returns the y position of the pingu
103
For backward comp. only */
104
const float& get_y () const { return pos_y; }
106
/** Checks if this action allows to be overwritten with the given new action */
107
bool change_allowed (Actions::ActionName new_action);
109
/// Check if the pingu is still alive
110
bool is_alive (void);
112
/// Return the status of the pingu
113
PinguStatus get_status (void) const;
115
PinguStatus set_status (PinguStatus);
117
/** The descriptive name of the action, this is used in the
118
CaputreRectangle, so it can contain more than just the name
119
(number of blocks, etc.) */
120
std::string get_name();
122
/// Returns the unique id of the pingu
123
unsigned int get_id (void);
125
/// Set the pingu to the given coordinates
126
void set_pos (float x, float y);
128
void set_x (float x);
130
void set_y (float y);
132
/// Set the pingu to the given coordinates
133
void set_pos (const Vector& arg_pos);
135
const Vector& get_velocity () const { return *velocity; }
137
void set_velocity (const Vector& velocity_);
139
// Set the pingu in the gives direction
140
void set_direction (Direction d);
142
/** Request an action to be set to the pingu, if its a persistent
143
action, it will be hold back for later execution, same with a
144
timed action, normal action will be applied if the current
145
action allows that. */
146
bool request_set_action (Actions::ActionName action_name);
148
/** Set an action without any checking, the action will take
149
instantly control. */
150
void set_action (Actions::ActionName action_name);
152
/// set the wall action if we have one
153
bool request_wall_action ();
155
/// set the fall action if we have one
156
bool request_fall_action ();
158
PinguAction* get_wall_action () { return wall_action; }
160
PinguAction* get_fall_action () { return fall_action; }
162
/** Returns the `color' of the colmap in the walking direction
164
(0, -1) is the pixel under the pingu
165
(1, 0) is the pixel in front of the pingu
167
int rel_getpixel (int x, int y);
169
/** Let the pingu catch another pingu, so that an action can be
170
applied (i.e. let a blocker change the direction f another
172
void catch_pingu (Pingu* pingu);
174
/** Returns true if the pingu needs to catch another pingu */
177
void draw (GraphicContext& gc);
178
void apply_force (Vector);
182
/** Indicate if the pingu's speed is above the deadly velocity */
183
//bool is_tumbling () const;
185
float get_z_pos () const { return 0; }
187
/** @return The owner_id of the owner, only used in multiplayer
188
configurations, ought to bed single player */
191
bool is_over (int x, int y);
193
bool is_inside (int x1, int y1, int x2, int y2);
195
double dist (int x, int y);
197
/** Return true if the pingu can be catched with the mouse and
198
another action can be applied, false otherwise (exiter,
202
/** @return the name of the action the Pingu currently has */
203
Actions::ActionName get_action ();
205
/** @return the action that was active before the action returned by
206
get_action() took place. This is used in a few situations where
207
an action needs to now what the Pingu was doing before the
208
action took place (faller->bomber translation is different
209
walker->bomber, etc.). */
210
Actions::ActionName get_previous_action() const { return previous_action; }
213
Pingu (const Pingu&);
214
Pingu& operator= (const Pingu&);
217
#endif /* PINGU_HH */