JNR
laStateObject.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_STATE_OBJECT_H
30 #define M_STATE_OBJECT_H
31 
33 
34 
46 
47 // Predefined states used by various derived classes
48 //
49 #define M_STATE_STAND 0
50 #define M_STATE_WALK 1
51 #define M_STATE_DIE 2
52 
53 #define M_STATE_ATTACK 3
54 
55 #define M_STATE_JUMP_U 4
56 #define M_STATE_JUMP_D 5
57 #define M_STATE_SOMERSAULT 6
58 
59 #define M_STATE_QATTACK 7
60 #define M_STATE_BSTAND 8 // battle stance
61 #define M_STATE_BWALK 9
62 
63 
65  public laObject
66 {
67  //Can be constructed from class name
68  CLASS_NAME(laStateObject);
69 
70 protected:
71 
72  laAnimatedModel _animBlend; // current transitional animation
73  laStaticModel _snapshot; // snaptshot of the origin state animation
74 
75  double _dBlendTime; // time to play the transition
76 
77  unsigned _nState; // state flags
78  //unsigned _nOldState;
79 
80  // This function determines state switches; Can be overloaded by laStateObject derivatives
81  //
82  virtual unsigned _next_state(unsigned nCurrentState );
83 
84 public:
85  // Constructor and destructor
86  //
87  laStateObject(void);
88  ~laStateObject(void);
89 
90  // Respawn object
91  //
92  virtual void respawn();
93 
94  // Switch to a different state
95  //
96  void state(unsigned nState, double dBlendTime = 0.1);
97  void setBlendTime(double t ) { _dBlendTime = t; }
98  laAnimatedModel* getStateModel();
99 
100  // Get state info
101  //
102  unsigned getState() { return _nState; }
103  //unsigned getOldState() { return _nOldState; }
104 
105  // Draw
106  //
107  virtual void _draw_positioned_rotated(laRenderer *r);
108  virtual void drawFx(laRenderer *r, laPoint3 ptBasePos);
109 
110  // Animate
111  //
112  virtual void animate(laTimer &t);
113 
114  // This method is part of the laLoadableObj interface
115  //
116  virtual void load(class laFileParser *fp);
117  virtual void create();
118 };
120 #endif
Animated 3D Model.
Multi-state Level Object.
Definition: laStateObject.h:64
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
Static 3D Model.
Definition: laStaticModel.h:44
Base Class for Level Objects.
Definition: laObject.h:43
File Parser.
Definition: laFileParser.h:41