~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/pingu.hxx

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-02-28 19:44:25 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080228194425-e8ilohlijv02kgcf
Tags: 0.7.2-2
* Fix FTBFS with gcc-4.3 by adding the missing include in
  src/input/evdev_device.cpp (Closes: #462238):
   + debian/patches/20_fix_FTBFS_with_gcc-4.3.
* Rename former patch so that the filename reflects the order in which
  the patches are applied:
   - debian/patches/data_dir.patch
   + debian/patches/10_fix_data_directory.
* Bump Standards-Version from 3.7.2 to 3.7.3, no changes needed.
* Add a dh_desktop call in the arch-dep part of debian/rules.
* Adjust the “missing-dep-for-interpreter guile” override since lintian
  now lists an alternative for that dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  $Id: pingu.hxx,v 1.24 2002/11/03 13:29:09 grumbel Exp $
2
 
//
3
 
//  Pingus - A free Lemmings clone
4
 
//  Copyright (C) 1999 Ingo Ruhnke <grumbel@gmx.de>
5
 
//
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.
10
 
//
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.
15
 
//
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.
19
 
 
20
 
#ifndef HEADER_PINGUS_PINGU_HXX
21
 
#define HEADER_PINGUS_PINGU_HXX
22
 
 
23
 
#include "direction.hxx"
24
 
#include "pingu_enums.hxx"
25
 
 
26
 
// Forward declarations
27
 
class Vector;
28
 
class ActionHolder;
29
 
class PinguAction;
30
 
class GraphicContext;
31
 
 
32
 
/** The class for managing one of the many penguins which are walking
33
 
    around in the World. All actions are handled by PinguAction
34
 
    objects. */
35
 
class Pingu
36
 
{
37
 
private:
38
 
  /** The primary action with is currently in use */
39
 
  PinguAction* action;
40
 
  
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;
44
 
 
45
 
  /** the action that gets triggered when the pingu hits a wall */
46
 
  PinguAction* wall_action;
47
 
 
48
 
  /** the action that gets triggered when the pingu falls */
49
 
  PinguAction* fall_action;
50
 
 
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;
55
 
 
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 */
58
 
  unsigned int id;
59
 
 
60
 
  int action_time;
61
 
  int owner_id;
62
 
 
63
 
  /// The stat of the pingu, these can be modified by PinguActions
64
 
  PinguStatus status;
65
 
  
66
 
  float pos_x;
67
 
  float pos_y;
68
 
  
69
 
  Vector* const velocity; 
70
 
 
71
 
  bool request_set_action (PinguAction*);
72
 
  void set_action (PinguAction*);
73
 
 
74
 
public:
75
 
 
76
 
  //FIXME make me private
77
 
  Direction direction;
78
 
 
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);
84
 
  
85
 
  /** Destruct the pingu... */
86
 
  ~Pingu ();
87
 
  
88
 
  /** Return the logical pingus position, this is the position which
89
 
      is used for collision detection to the ground (the pingus
90
 
      feet) */
91
 
  Vector get_pos () const;
92
 
 
93
 
  /** Returns the visible position of the pingu, the graphical center
94
 
      of the pingu. */
95
 
  Vector get_center_pos () const;
96
 
 
97
 
  /** Returns the x position of the pingu
98
 
   * For backward comp. only
99
 
   */
100
 
  const float& get_x () const { return pos_x; }
101
 
 
102
 
  /** Returns the y position of the pingu
103
 
      For backward comp. only */
104
 
  const float& get_y () const { return pos_y; }
105
 
 
106
 
  /** Checks if this action allows to be overwritten with the given new action */
107
 
  bool change_allowed (Actions::ActionName new_action);
108
 
 
109
 
  /// Check if the pingu is still alive
110
 
  bool is_alive (void);
111
 
 
112
 
  /// Return the status of the pingu
113
 
  PinguStatus get_status (void) const; 
114
 
 
115
 
  PinguStatus set_status (PinguStatus);
116
 
 
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();
121
 
 
122
 
  /// Returns the unique id of the pingu
123
 
  unsigned int  get_id (void); 
124
 
    
125
 
  /// Set the pingu to the given coordinates
126
 
  void set_pos (float x, float y);
127
 
 
128
 
  void set_x (float x);
129
 
  
130
 
  void set_y (float y);
131
 
 
132
 
  /// Set the pingu to the given coordinates
133
 
  void set_pos (const Vector& arg_pos);
134
 
 
135
 
  const Vector& get_velocity () const { return *velocity; }
136
 
  
137
 
  void set_velocity (const Vector& velocity_);
138
 
      
139
 
  // Set the pingu in the gives direction
140
 
  void set_direction (Direction d);
141
 
 
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);
147
 
 
148
 
  /** Set an action without any checking, the action will take
149
 
      instantly control. */
150
 
  void set_action (Actions::ActionName action_name);
151
 
  
152
 
  /// set the wall action if we have one
153
 
  bool request_wall_action ();
154
 
  
155
 
  /// set the fall action if we have one
156
 
  bool request_fall_action ();
157
 
 
158
 
  PinguAction* get_wall_action () { return wall_action; }
159
 
  
160
 
  PinguAction* get_fall_action () { return fall_action; }
161
 
 
162
 
  /** Returns the `color' of the colmap in the walking direction 
163
 
      Examples: 
164
 
      (0, -1) is the pixel under the pingu
165
 
      (1, 0)  is the pixel in front of the pingu
166
 
  */
167
 
  int  rel_getpixel (int x, int y);
168
 
 
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
171
 
      pingu) */
172
 
  void catch_pingu (Pingu* pingu);
173
 
 
174
 
  /** Returns true if the pingu needs to catch another pingu */
175
 
  bool need_catch ();
176
 
  
177
 
  void draw (GraphicContext& gc);
178
 
  void apply_force (Vector);
179
 
  
180
 
  void update();
181
 
  
182
 
  /** Indicate if the pingu's speed is above the deadly velocity */
183
 
  //bool is_tumbling () const;
184
 
  
185
 
  float get_z_pos () const { return 0; }
186
 
 
187
 
  /** @return The owner_id of the owner, only used in multiplayer
188
 
      configurations, ought to bed single player */
189
 
  int get_owner ();
190
 
 
191
 
  bool   is_over (int x, int y);
192
 
 
193
 
  bool   is_inside (int x1, int y1, int x2, int y2);
194
 
 
195
 
  double dist (int x, int y);
196
 
 
197
 
  /** Return true if the pingu can be catched with the mouse and
198
 
      another action can be applied, false otherwise (exiter,
199
 
      splashed, etc.) */
200
 
  bool catchable ();
201
 
 
202
 
  /** @return the name of the action the Pingu currently has */
203
 
  Actions::ActionName get_action ();
204
 
 
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; }
211
 
 
212
 
private:
213
 
  Pingu (const Pingu&);
214
 
  Pingu& operator= (const Pingu&);  
215
 
};
216
 
 
217
 
#endif /* PINGU_HH */
218
 
 
219
 
/* EOF */