# ifndef CAR_HEADER_FILE
# define CAR_HEADER_FILE

// Basiques
# include <iostream>
# include <cmath>
# include <vector>

// Random
# include <ctime>
# include <cstdlib>

// SDL
# include <SDL/SDL.h>
# undef main
# include <SDL/SDL_rotozoom.h>
# include <SDL/SDL_gfxPrimitives.h>

// bBox2D
# include <box2d/box2d.h>
# define MULTI 100.0f

enum command { FREE, BREAK, GO, REVERSE };

class Car
{
/// Méthodes
public:
	Car();
	virtual ~Car();

	void destroy( b2World &world );
	virtual void init( b2World &world, float x, float y, float angle = 0.0f ) = 0;

	void drive( command cmd );
	void jump( float correction = 0.0f );
	void spin( float tq );
	virtual void update();

	b2Vec2 GetPosition();
	b2Vec2 GetVelocity();
	float GetTorque();
	float GetSpeed();
	bool GetIsOnGround();

protected:
	void createMotorWheel( b2World &world, b2Vec2 rel, float friction = 10.0f, float density = 0.25f );
	void createFreeWheel( b2World &world, b2Vec2 rel, float friction = 10.0f, float density = 0.25f );
	void createCarenage( b2World &world, float x, float y, float friction = 1.0f, float density = 1.0f );

/// Attributs
protected:
	SDL_Surface* m_imgCar ;
	SDL_Surface* m_imgWheel ;

private:
	b2Body* m_bodyCar ;
	std::vector< b2Body* > m_bodyWheel ;

	std::vector< b2RevoluteJoint* > m_motorAxe ;
	std::vector< b2RevoluteJoint* > m_fwdAxe ;


	command m_cmd ;

	float m_currentTorque ;
	float m_currentSpeed ;
	float m_sense ;
	float m_latence ;

	float m_goTorque ;
	float m_minTorque ;
	float m_maxSpeed ;
};


# endif // CAR_HEADER_FILE