Car.h 929 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # ifndef CAR_HEADER_FILE
  2. # define CAR_HEADER_FILE
  3. // Basiques
  4. # include <iostream>
  5. # include <cmath>
  6. # include <vector>
  7. // Random
  8. # include <ctime>
  9. # include <cstdlib>
  10. // SDL
  11. # include <SDL/SDL.h>
  12. # undef main
  13. # include <SDL/SDL_rotozoom.h>
  14. # include <SDL/SDL_gfxPrimitives.h>
  15. // bBox2D
  16. # include <box2d/box2d.h>
  17. # define MULTI 100.0f
  18. enum command { FREE, BREAK, GO, REVERSE };
  19. class Car
  20. {
  21. public:
  22. Car();
  23. virtual ~Car();
  24. void init( b2World &world, float x, float y, float angle = 0.0f );
  25. void drive( command cmd );
  26. void update();
  27. b2Vec2 GetPosition();
  28. protected:
  29. b2Body* m_bodyCar ;
  30. b2Body* m_bodyWheelFwd ;
  31. b2Body* m_bodyWheelBack ;
  32. b2RevoluteJoint* m_motorAxe ;
  33. b2RevoluteJoint* m_fwdAxe ;
  34. SDL_Surface* m_imgCar ;
  35. SDL_Surface* m_imgWheel ;
  36. command m_cmd ;
  37. float m_currentTorque ;
  38. float m_currentSpeed ;
  39. float m_goTorque ;
  40. float m_minTorque ;
  41. float m_maxSpeed ;
  42. };
  43. # endif // CAR_HEADER_FILE