JNR
laMovingCreature.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 #ifndef M_MOVING_CREATURE_H
30 #define M_MOVING_CREATURE_H
31 
33 
34 
40 
42  public laStateObject
43 {
44  //Can be constructed from class name
45  CLASS_NAME(laMovingCreature);
46 
47 protected:
48 
49  // Moving creature RPG properties
50  //
51  // NOTE: This class (laMovingCreature) instantiates rpgSheet_Acrobate;
52  // By passing a different rpgSheet-derrived object to the constructor
53  // it is possible to use a different RPG sheet adding more parameters.
54  //
55  rpgSheet* _pSheet;
56 
57  // Movement flags and triggers
58  //
59  M_BOOL _bControlEnabled;
60  M_BOOL _bExplicitFacing; // if set, facing direction can be != movement direction
61 
62  int _nFaceDirection;
63  int _nMovementDirection;
64 
65  laTimeTrig _ttTurn;
66 
67  M_BOOL _bJumping;
68  laTimeTrig _ttSomersault;
69 
70  laPivot _ptOriginPos; // used to respawn
71 
72  virtual unsigned _next_state( unsigned nCurrentState );
73 
74  virtual void _update_facing( double dir_x );
75 
76 public:
77 
78  // Trail FX
79  //
80  fxParticleSystem _fxTrail;
81 
82  //Constructor/destructor
83  //
84  laMovingCreature(rpgSheet* pSheet = NULL);
85  virtual ~laMovingCreature(void);
86 
87  rpgSheet* getSheet() { return _pSheet; }
88 
89  // Respawn creature
90  //
91  virtual void respawn();
92  laPoint3 getOriginalPos() { return _ptOriginPos; }
93 
94  // Movement control
95  //
96  void enableControl(M_BOOL on = M_TRUE) { if(!on) move(0); _bControlEnabled = on; }
97  M_BOOL isControlEnabled() { return _bControlEnabled; }
98 
99  virtual void move(int direction); // basic horizontal movement
100  int getMoveDirection() { return _nMovementDirection; }
101 
102  virtual void move_v(laPoint3 dir); // advanced movement, specify a direction vector
103 
104  virtual M_BOOL jump(); //returns true if the jump is succesful
105  virtual void somersault();
106 
107  // Explicit direction control
108  //
109  void setFaceDirection(int nDirection);
110  int getFaceDirection() { return _nFaceDirection; }
111 
112  void setExplicitFacing(M_BOOL bExplicit){
113  _bExplicitFacing = bExplicit;
114  }
115 
116  M_BOOL isFacingExplict() { return _bExplicitFacing; }
117 
118  // Animate
119  //
120  void animate(laTimer &t);
121 
122  // Draw
123  //
124  void drawGeometry(laRenderer *r, laPoint3 ptBasePos);
125  void _drawFx_positioned(laRenderer *r);
126 
127  // Load
128  void load(class laFileParser *fp);
129 };
131 #endif
Moving Creature.
Multi-state Level Object.
Definition: laStateObject.h:64
Abstract RPG Properties Sheet.
Definition: rpgSheet.h:107
Time-triggered events.
Definition: laTimeTrig.h:41
Dynamic Object Pivot.
Definition: laPivot.h:44
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
virtual void move(int direction)
virtual void somersault()
File Parser.
Definition: laFileParser.h:41