Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Explosive Race - Car.cpp

Car.cpp

Caricato da: RiccardoG97
Scarica il programma completo

  1. #include "Car.h"
  2. #include "allegro.h"
  3.  
  4. Car::Car ( void )
  5. {
  6.     car = load_bmp ( "Car.bmp", colors );
  7.     xCar = 300;
  8. }
  9.  
  10. Car::~Car ( void )
  11. {
  12.     destroy_bitmap ( car );
  13. }
  14.  
  15. void Car::makeCar ( BITMAP *buffer )
  16. {
  17.     draw_sprite ( buffer, car, xCar, 430 );
  18. }
  19.  
  20. void Car::moveCar ( int speed )
  21. {
  22.     if ( ( key[KEY_LEFT] ) && ( xCar >= 45 ) )
  23.         xCar -= speed * 0.6;
  24.     if ( ( key[KEY_RIGHT] ) && ( xCar <= 493 ) )
  25.         xCar += speed * 0.6;
  26. }
  27.  
  28. int Car::getX ( void )
  29. {
  30.     return xCar;
  31. }