/*
	Wheels Of Steel
	Copyright (c) 2006, Darragh Coy.
	All rights reserved.
	Original work(s), source code & author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in source and binary forms, with or without modification, are permitted 
	provided that the following conditions are met:

		* 	Redistributions of source code must retain the above copyright notice, this list of 
			conditions and the following disclaimer.
		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
		* 	The use of any third party libraries, modules or data files provided with the source 
			form of the program must follow and respect the individual licensing terms of these 
			components. You do not have permission to modify or circumvent the licensing terms for 
			provided third party components unless the third party licenses specifically allow this. 
			If you do not agree to the terms of provided third party components then you do not have 
			permission to use them in your derived work(s).
		* 	The terms of this license do not apply to separate (but related) distributions if supplied 
			by the author(s), only to the contents of this source distribution, derived works, and the 
			binaries produced by either modified or unmodified versions of the source code. The terms 
			of this license do not also apply to any third party libraries or components provided with 
			the source distribution. Such third party elements are licensed under their own separate 
			agreements.

	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef OBJ_CAR_H
#define OBJ_CAR_H

//##############################################################################
// Have to include base class firstly or compiler will complain
//##############################################################################

#include "GameObject.h"

//##############################################################################
// Forward declarations
//##############################################################################

class Timer;
class GameObjectManager;
class Mipmap;
class Window;
class Camera;
class Obj_SnowPuff;

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   Obj_Car
// Purpose:      Class for all cars in the game.
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class Obj_Car : public GameObject
{

 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Public functions and data
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

 public:

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Constants
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        // normal speed at which the car accelerates: may be reduced for ai cars by whatever handicaps the user has picked

        static const float CAR_ACCELERATION;

        // speed at which the car brakes

        static const float CAR_DEACCELERATION;

        // Car dimensions

        static const float CAR_SIZE_X;			// size of car: x
        static const float CAR_SIZE_Y;			// size of car: y
        static const float CAR_SIZE_Z;			// size of car: z

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Functions
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        // Constructor

        Obj_Car
        (
            const Mipmap ** mipArrayCar,      // Array of 7 car images for various orientations of the car. The 'skin' of the car.
            float pos_x,                // position: x
            float pos_y,                // position: y
            float pos_z,                // position: z
            float acceleration          // ultimately affects the max speed of the car
        );

        // Destructor

        ~Obj_Car();

        // collision with object event

        void event_collision( GameObject * collider);

        // draw event

        void event_draw( Window & window, Camera * camera );

        // move event

        void event_move( Track * track , float frameTime );

        // Car actions

        void accelerate ();
        void brake      ();
        void turnLeft   ();
        void turnRight  ();

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Private functions and data
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

private:

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Constants
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        static const float CAR_TORQUE;						// times the velocity the amount the car can turn
        static const float CAR_WEIGHT;						// the weight of each car
        static const float CAR_IMAGE_CHANGE_DEGREES;		// Number of degrees turning that causes the car image to change
        static const float CAR_SCORE_TO_SNOW_PUFF;			// The 'score' required to make a snow puff: see explanation below

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Variables
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        // Pointer to an array holding 7 mipmap images for different orientations of the car

        const Mipmap ** mipArrayCar;

        // Amount of forward acceleration for this car. affects max speed.

        float acceleration;

        // An odd variable to say the least. I define a 'score' (for lack of a better word) that controls
        // when the car should generate a snow puff object. Every time the car is in the
        // rough the score is increased by the velocity of the car times the frame rate (in seconds)
        // When the score has reached a certain amount a snow puff is created. So the faster or longer the
        // car is going in the rough, the more snow puffs it makes. nuff said...

        float snowPuffScore;

}; // end of: class Obj_Car

//##############################################################################
// C++ Includes
//##############################################################################

#include "Timer.h"
#include "GameObjectManager.h"
#include "Mipmap.h"
#include "Window.h"
#include "Camera.h"
#include "Obj_SnowPuff.h"

#endif // end of: ifndef OBJ_CAR_H
