00001 // --------------------------------------------------------------------------- 00002 // PLATFORM: All - 00003 // PRODUCT: Fourplay - 00004 // VISIBILITY: Public - 00005 // --------------------------------------------------------------------------- 00006 // - 00007 // PURPOSE: Discs which will be fired at the grid. - 00008 // - 00009 // --------------------------------------------------------------------------- 00010 00011 #ifndef DISC_H 00012 #define DISC_H 00013 00014 #include "GameConstants.h" 00015 #include <utility> 00016 #include <time.h> 00017 #include <string> 00018 #include <vector> 00019 #include <sstream> 00020 #include "input.h" 00021 #include <IwGxFont.h> 00022 #include "PhysicsObject.h" 00023 #include "CollisionManager.h" 00024 #include "AudioManager.h" 00025 #include "Net.h" 00026 00032 class Disc 00033 { 00034 public: 00036 enum DiscType { YELLOW, RED }; 00037 00043 Disc(CIwFVec2 position, 00044 DiscType discColour); 00045 00049 ~Disc(); 00050 00055 void Draw(double deltaTime); 00056 00062 void DrawTrajectory(float currentStep, 00063 float totalSteps); 00064 00069 void Launch(CIwFVec2 velocity); 00070 00075 void Update(double deltaTime); 00076 00080 void HandleInput(); 00081 00085 void KeepInRange(); 00086 00090 void SetOffset(); 00091 00096 void UpdatePhysics(double deltaTime); 00097 00102 CIwFVec2 GetDrawPosition(); 00103 00108 void SetDrawPosition(CIwFVec2 position); 00109 00114 void SetPhysicsObjectPosition(CIwFVec2 position); 00115 00119 void UpdateGridLogic(); 00120 00125 bool IsActive(); 00126 00131 PhysicsObject* GetPhysicsObject(); 00132 00139 void SetTarget(float y, 00140 int column, 00141 int row); 00142 00147 std::pair<int, int> GetGridTarget(); 00148 00153 bool HasTarget(); 00154 00159 void SetHasTarget(bool toggle); 00160 00165 int GetColour(); 00166 00171 bool HasLanded(); 00172 00178 bool HasClearedGrid(); 00179 00184 char* PositionToString(); 00185 00191 CIwFVec2 StringToPosition(std::string str); 00192 00197 void SetIsStuck(bool toggle); 00198 00203 bool GetIsStuck(); 00204 00205 protected: 00207 CIwFVec2 m_position; 00208 00210 CIwFVec2 m_offsetPosition; 00211 00213 CIwFVec2 m_initialPosition; 00214 00216 CIw2DImage *m_texture; 00217 00219 PhysicsObject *m_physicsObject; 00220 00222 DiscType m_discType; 00223 00225 uint32 m_colour; 00226 00228 float m_radius; 00229 00231 int m_targetYPos; 00232 00234 bool m_hasTarget; 00235 00237 bool m_hasLanded; 00238 00240 bool m_isStuck; 00241 00243 bool m_hasClearedGrid; 00244 00246 std::pair<int, int> m_gridPos; 00247 00249 bool m_isGrabbed; 00250 00252 static const int m_drawRange = 120; 00253 00255 CIwFVec2 m_prevPosition; 00256 00258 float m_trajectoryAnimator; 00259 00261 CIw2DFont *m_font; 00262 00264 float m_twoPi; 00265 00267 float m_trajectoryRadius; 00268 00270 static const int m_trajectoryDrawSegments = 16; 00271 00273 static const int m_alphaFadeRate = 3; 00274 00276 static const int m_trajectoryMax = 2; 00277 00279 float m_trajectoryInitial; 00280 00282 float m_trajectorySpeed; 00283 00285 static const int m_trajectorySteps = 20; 00286 00288 float m_trajectoryScale; 00289 00291 static const int m_cumulativeOffset = 3; 00292 00294 float m_gridYPos; 00295 00297 float m_gravity; 00298 }; 00299 00300 #endif