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
Rocket Pong - BluePaddle.cpp

BluePaddle.cpp

Caricato da: RiccardoG97
Scarica il programma completo

  1. #include "BluePaddle.h"
  2. #include "SDL.h"
  3.  
  4. BluePaddle::BluePaddle ( void )
  5. {
  6.     bluePaddle = SDL_LoadBMP ( "BluePaddle.bmp" );
  7.     dst.x = 20;
  8.         dst.y = 200;
  9. }
  10.  
  11. BluePaddle::~BluePaddle ( void )
  12. {
  13.     SDL_FreeSurface ( bluePaddle );
  14. }
  15.  
  16. void BluePaddle::makeBluePaddle ( SDL_Surface *screen )
  17. {
  18.     SDL_BlitSurface ( bluePaddle, NULL, screen, &dst );
  19. }
  20.  
  21. void BluePaddle::moveBluePaddle ( Uint8 *keys )
  22. {
  23.     if ( ( keys[SDLK_UP] == SDL_PRESSED ) && ( dst.y > 55 ) )
  24.         dst.y -= 4;
  25.     if ( ( keys[SDLK_DOWN] == SDL_PRESSED ) && ( dst.y < 333 ) )
  26.         dst.y += 4;
  27. }
  28.  
  29. int BluePaddle::giveYBluePaddle ( void )
  30. {
  31.     return dst.y;
  32. }