Guest User

Untitled

a guest
Apr 1st, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 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.     delete gameGraphics;
  13.     SDL_DestroyTexture(Texture);
  14. }
  15.  
  16. SDL_Texture* gameSprite::loadSprite(std::string filePath)
  17. {
  18.     tempSurface = IMG_Load(filePath.c_str());
  19.     if (tempSurface == nullptr)
  20.     {
  21.         printf("Error loading Sprite %s", filePath);
  22.     }
  23.  
  24.     Texture = SDL_CreateTextureFromSurface(gameGraphics->getRenderer(), tempSurface);
  25.     SDL_FreeSurface(tempSurface);
  26.  
  27.     return Texture;
  28. }
  29.  
  30. void gameSprite::draw()
  31. {
  32.     SDL_RenderCopy(gameGraphics->getRenderer(), Texture, NULL, NULL);
  33. }
Add Comment
Please, Sign In to add comment