/*
	Asteroids
    Copyright (C) 2006  Darragh Coy.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*##############################################################################

Header name: GLDraw.hpp

##############################################################################*/

#ifndef GAME_HPP
#define GAME_HPP

   /****************************************************************************
   Defines
   ****************************************************************************/
   
      #define GAME_VERSION 1.0f

      // Trim unnecssary stuff from windows library
   
      #define WIN32_LEAN_AND_MEAN    

   /****************************************************************************
   Includes
   ****************************************************************************/

      #include <windows.h>       // Windows key codes                                                  
      #include "GLDraw.h"        // Drawing module
      #include "ShowScores.h"    // Display the high scores to user in html format
      #include "Vec2D.h"         // Vectors
      #include "Player.h"        // Player structure etc.
      #include "Stars.h"         // Stars
      #include "Asteroid.h"      // Asteroids
      #include "Bullet.h"        // Bullets
      #include "Particle.h"      // Particles
      #include "Timer.h"         // Game timer: use for framerate independant movement
      #include "Saves.h"         // Saving the game
   
   /****************************************************************************
   Externs
   ****************************************************************************/   
      
      // Various game variables
      
      extern unsigned int  highScore;
      extern bool gamePaused;
      extern bool enteringName;
      extern char playerName[]; 
      extern char lastPlayerName[];    
      extern char highScoreName[];
      
      // Performance logging
      
      extern bool showPerformanceInfo;
      extern int  clocks_draw;
      extern int  clocks_game;      
      
   /****************************************************************************
   Structs and enums
   ****************************************************************************/
    
      // The player structure
    
      struct Player_t
      {        
        // Other data
        
        bool              playerAlive;   // Is the player alive still ?                                      
        float             orientation;   // Angle
        struct Vec2D_t    velocity;      // Speed in a given direction
        unsigned int      score;         // Players current score
        unsigned int      scoreHighest;  // Players highest score
        long double       timeSinceFire; // Time elapsed since last bullet fire
      };    
      
      // The asteroid structure
      
      struct Asteroid_t
      {
        float           orientation;             // Current orientation    
        float           rotationAmt;             // Rotation amount
        bool            asteroidAlive;           // Is the asteroid alive ?
        bool            asteroidHalf;            // Is this a half asteroid ?
        float           collisionRadius;         // Radius of bounding circle around asteroid
        struct Vec2D_t  center;                  // Where abouts is the asteroid positioned ?
        struct Vec2D_t  velocity;                // Speed in a direction
        struct Vec2D_t  rotationCenter;          // Point which the asteroid rotates about
        struct Vec2D_t  points[AST_NUM_POINTS];  // Asteroid points
      };
      
      // The bullet structure      
      
      struct Bullet_t
      {
        bool           bulletAlive;     // Is the bullet alive ?
        struct Vec2D_t position;        // Position of the bullet
        struct Vec2D_t velocity;        // Which way and how fast is bullet moving ?
      };
     
      // Everything we need to save (all that is important) goes here
      
      struct GameData_t 
      {
         // The player data   
             
         Player_t player;                          
         
         // Asteroids: make double size to allow for half asteroids. When spawning
         // the program searches for free slots in the first half of the array.
         // The other half is to allow for splits. It may happen that the second
         // half of the array is not free when a split happens, but this is unlikely
         
         Asteroid_t asteroids[AST_MAX_ASTEROIDS*2];  
         
         // Array of bullets
         
         Bullet_t bullets[BUL_MAX_BULLETS];                                         
      };
   
   /****************************************************************************
   Prototypes
   ****************************************************************************/   

   void Game_Init();              // Game initialisation                                          
   void Game_End();               // Game end
   void Game_DoGameLoop();        // Does the game loop
   
#endif
