Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "gameSprite.h"
- gameSprite::gameSprite()
- {
- Texture = nullptr;
- tempSurface = nullptr;
- gameGraphics = new gameMain();
- }
- gameSprite::~gameSprite()
- {
- delete gameGraphics;
- SDL_DestroyTexture(Texture);
- }
- SDL_Texture* gameSprite::loadSprite(std::string filePath)
- {
- tempSurface = IMG_Load(filePath.c_str());
- if (tempSurface == nullptr)
- {
- printf("Error loading Sprite %s", filePath);
- }
- Texture = SDL_CreateTextureFromSurface(gameGraphics->getRenderer(), tempSurface);
- SDL_FreeSurface(tempSurface);
- return Texture;
- }
- void gameSprite::draw()
- {
- SDL_RenderCopy(gameGraphics->getRenderer(), Texture, NULL, NULL);
- }
Add Comment
Please, Sign In to add comment