# ifndef CAR_HEADER_FILE # define CAR_HEADER_FILE // Basiques # include # include # include // Random # include # include // SDL # include # undef main # include # include // bBox2D # include # 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, float32 x, float32 y, float32 angle = 0.0f ) = 0; void drive( command cmd ); void jump( float32 correction = 0.0f ); void spin( float32 tq ); virtual void update(); b2Vec2 GetPosition(); b2Vec2 GetVelocity(); float32 GetTorque(); float32 GetSpeed(); bool GetIsOnGround(); protected: void createMotorWheel( b2World &world, b2Vec2 rel, float32 friction = 10.0f, float32 density = 0.25f ); void createFreeWheel( b2World &world, b2Vec2 rel, float32 friction = 10.0f, float32 density = 0.25f ); void createCarenage( b2World &world, float32 x, float32 y, float32 friction = 1.0f, float32 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 ; float32 m_currentTorque ; float32 m_currentSpeed ; float32 m_sense ; float32 m_latence ; float32 m_goTorque ; float32 m_minTorque ; float32 m_maxSpeed ; }; # endif // CAR_HEADER_FILE