Frapper  1.0a
S3DGame.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2009 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; version 2.1 of the License.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
21 -----------------------------------------------------------------------------
22 */
23 
32 
33 #ifndef S3DGAME_H
34 #define S3DGAME_H
35 
36 #include "OgreContainer.h"
37 #include "OgreTools.h"
38 
39 #include "S3DGameNode.h"
40 
41 #include <QTime>
42 
43 namespace S3DGameNode {
44 using namespace Frapper;
45 
49 class S3DGame : public S3DGameNode
50 {
51  Q_OBJECT
52 
53 public: // constructors and destructors
54 
61  S3DGame ( const QString &name, ParameterGroup *parameterRoot );
62 
70  virtual ~S3DGame ();
71 
72 
73 public: // functions
74 
75 private slots:
76 
80  void updateGame();
81 
85  void timerEvent();
86 
90  virtual void loadReady();
91 
92 private: //data
93 
98 
102 
103  // action flags
104  bool mP1Action;
105  bool mP2Action;
106 
107  // animation flags and timer
109 
114 
115  // Player character timing for movement
116  int mPCTime, mPCLoopTime, mPCStep;
117 
118  // Platform timings
119  bool mPlatform1, mPlatform2, mPlatform3;
120  int mPlatform1Time, mPlatform2Time, mPlatform3Time;
121  float mPlatform1Alpha, mPlatform2Alpha, mPlatform3Alpha;
122 
123  // Timing of endscreen
124  int mEndScreenTime, mEndScreenTimeMax;
125 
126  float mLavaTimer;
127 
128  // The animated door object
130 
131  Ogre::Vector3 mOrigin;
132 
133  // flag used when a jump path needs to be created as next path
134  bool mCreateJump, mCreateFall, mCreateDive;
135 
136  QTime mTime;
137  int mElapsed;
138 
139 protected: //functions
140 
141  virtual void ResetGame();
142 
143 private:
144 
145  void UpdateCharacterPosition( Path* path, float alpha, float height );
146  void ProcessEvents();
147 
148  void UpdateWorldObjects();
149  void AdvanceToNextPath( Path* overNextPath = NULL);
150 
151 
152  bool CheckReady();
153  void AdvanceTime( int &time, const int &step, const int &max );
154  void AdvanceTimeReset( int &time, const int &step, const int &max );
155  void AdvanceTimeReset( float &time, const float &step, const float &max );
156  void PlayDeathAnim();
157  void UpdatePlatforms();
158 
159  void SetTransparency( QString materialName, float alpha );
160 
161  float getPlatformTransparency( float alpha );
162  float getPlatformMoveAlpha( float alpha );
163 
164  void UpdateCharacter();
165  void AnimateLava();
166 };
167 
168 } // namespace S3DGameNode
169 #endif