Guest User

Untitled

a guest
Apr 1st, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include "gameSprite.h"
  2.  
  3. gameSprite::gameSprite()
  4. {
  5.     Texture = nullptr;
  6.     tempSurface = nullptr;
  7.     gameGraphics = new gameMain();
  8. }
  9.  
  10. gameSprite::~gameSprite()
  11. {
  12.     SDL_DestroyTexture(Texture);
  13. }
  14.  
  15. SDL_Texture* gameSprite::loadSprite(std::string filePath)
  16. {
  17.     tempSurface = IMG_Load(filePath.c_str());
  18.     if (tempSurface == nullptr)
  19.     {
  20.         printf("Error loading Sprite %c", filePath);
  21.     }
  22.  
  23.     Texture = SDL_CreateTextureFromSurface(gameGraphics->getRenderer(), tempSurface);
  24.     SDL_FreeSurface(tempSurface);
  25.  
  26.     return Texture;
  27. }
  28.  
  29. void gameSprite::draw()
  30. {
  31.     SDL_RenderCopy(gameGraphics->getRenderer(), Texture, NULL, NULL);
  32. }
Add Comment
Please, Sign In to add comment