35 lines
986 B
C++
35 lines
986 B
C++
/*
|
|
* TextureManager.cpp
|
|
*
|
|
* Created on: Feb 11, 2020
|
|
* Author: ayoungblood
|
|
*/
|
|
|
|
#include "TextureManager.h"
|
|
|
|
SDL_Texture* TextureManager::LoadTexture(const char* texture)
|
|
{
|
|
SDL_Surface* tempSurface = IMG_Load(texture);
|
|
SDL_Texture* tex = SDL_CreateTextureFromSurface(Game::renderer, tempSurface);
|
|
SDL_FreeSurface(tempSurface);
|
|
return tex;
|
|
}
|
|
|
|
void TextureManager::Draw(SDL_Texture* tex, SDL_Rect src, SDL_Rect dest, SDL_RendererFlip flip)
|
|
{
|
|
SDL_RenderCopyEx(Game::renderer, tex, &src, &dest, NULL, NULL, flip);
|
|
}
|
|
|
|
void TextureManager::DrawCollider(SDL_Rect colliderRect)
|
|
{
|
|
Vector2D pt1, pt2, pt3, pt4;
|
|
pt1 = Vector2D(colliderRect.x,colliderRect.y);
|
|
pt2 = Vector2D(colliderRect.w-2,colliderRect.y);
|
|
pt3 = Vector2D(colliderRect.x,colliderRect.h-2);
|
|
pt4 = Vector2D(colliderRect.w-2,colliderRect.h-2);
|
|
Game::drawLine(pt1,pt2,255,0,255);
|
|
Game::drawLine(pt1,pt3,255,255,0);
|
|
Game::drawLine(pt2,pt4,0,0,255);
|
|
Game::drawLine(pt3,pt4,0,255,0);
|
|
}
|