src/StateBattle/Battle.h

Go to the documentation of this file.
00001 /* Crown and Cutlass
00002  * Naval Battle GameState Header
00003  */
00004 
00005 #if !defined( _BATTLE_H_ )
00006 
00007 #define _BATTLE_H_
00008 
00009 #include <list>
00010 #include <guichan.hpp>
00011 #include "SDL.h"
00012 #include "../GLee.h"
00013 #include "../IGameState.h"
00014 #include "StateDone.h"
00015 
00016 using namespace std;
00017 
00018 // So I don't have to include the headers
00019 class Camera;
00020 class Bullet;
00021 class ShipAI;
00022 class StateDone;
00023 class SkyDome;
00024 class SoundEffect;
00025 class Texture;
00026 class Ship;
00027 class CCTable;
00028 
00029 class Battle: public IGameState {
00030  public:
00031   // Constructor
00032   Battle();
00033 
00034   // Destructor
00035   ~Battle();
00036 
00037   // Need to implement the Update and Display functions
00038   void Update(const unsigned int ticks);
00039   void Display();
00040 
00041   // Need to implement the switchTo function
00042   void SwitchTo(IGameState *oldState);
00043 
00044   // Need to implement the switchFrom function
00045   void SwitchFrom();
00046 
00047  private:
00048   // Handles processing SDL events
00049   void CheckInput();
00050 
00051   // Keyboard handler functions
00052   void HandleKeyUp(SDL_keysym* keysym);
00053   void HandleKeyDown(SDL_keysym* keysym);
00054 
00055   // Timer function to handle time-based movement
00056   void Timer(const unsigned int ticks);
00057 
00058   // Fire cannons
00059   void PlayerFire(float rotDiff);
00060   void EnemyFire(float rotDiff);
00061 
00062   // Record a collision
00063   void PlayerHit();
00064   void EnemyHit();
00065 
00066   void BattleFinished(BattleResult result);
00067 
00068   // Generate the water display list
00069   void GenerateWaterList();
00070 
00071   // Helper function for generateWaterList
00072   float CalcBottomDepth(float x, float z, float bottomSize);
00073 
00074   // Initialize the HUD
00075   void InitHUD();
00076 
00077   // Sets all of the HUD lables based on ship values
00078   void ResetLabelValues();
00079 
00080   // Current time of day (0 to 24)
00081   float m_time;
00082 
00083   // Ship model
00084   Ship *m_ship;
00085   Ship *m_enemyShip;
00086 
00087   // Object to hand AI for enemy ship
00088   ShipAI *m_enemyAI;
00089 
00090   // Sky dome object
00091   SkyDome *m_skyDome;
00092 
00093   int m_playerTicksToReload;
00094   int m_enemyTicksToReload;
00095 
00096   bool m_battleDone;
00097   BattleResult m_result;
00098 
00099   // List of cannon balls in the air
00100   list <Bullet*> m_bullets;
00101 
00102   // Camera location
00103   Camera *m_camera;
00104   GLfloat m_cameraX, m_cameraY, m_cameraZ;
00105 
00106   // State to go to after battle is done
00107   StateDone *m_leaveState;
00108 
00109   // Light info
00110   GLfloat m_ambientLight[4];
00111   GLfloat m_diffuseLight[4];
00112   GLfloat m_lightPosition[4];
00113 
00114   GLfloat m_waterMaterial[4];
00115   GLfloat m_bottomMaterial[4];
00116   GLfloat m_bulletMaterial[4];
00117 
00118   Texture *m_waterTexture;
00119   Texture *m_bottomTexture;
00120 
00121   // Display list for water and bottom of ocean
00122   GLuint m_waterList;
00123 
00124   SoundEffect *m_playerCannonSound;
00125   SoundEffect *m_enemyCannonSound;
00126 
00127   SoundEffect *m_playerHitSound;
00128   SoundEffect *m_enemyHitSound;
00129 
00130   CCTable* m_playerTable;
00131   CCLabel* m_playerSailsLabel;
00132   CCLabel* m_playerDamageLabel;
00133   CCLabel* m_playerReloadLabel;
00134 
00135   CCTable* m_enemyTable;
00136   CCLabel* m_enemySailsLabel;
00137   CCLabel* m_enemyDamageLabel;
00138   CCLabel* m_enemyReloadLabel;
00139 
00140   // Font names
00141   static const std::string s_mainFontName;
00142 };
00143 
00144 #endif

Generated on Mon Jan 8 22:34:12 2007 for CrownandCutlass by  doxygen 1.4.7