Fixed up collision boxes allowing custom colliders

This commit is contained in:
2021-02-15 00:30:26 -05:00
parent 19f160b6ea
commit 78629be4d8
8 changed files with 69 additions and 41 deletions

View File

@ -17,6 +17,18 @@ SDL_Texture* TextureManager::LoadTexture(const char* texture)
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);
}

View File

@ -16,8 +16,7 @@ class TextureManager
public:
static SDL_Texture* LoadTexture(const char* fileName);
static void Draw(SDL_Texture* tex, SDL_Rect src, SDL_Rect dest, SDL_RendererFlip flip);
static void DrawCollider(SDL_Rect colliderRect);
};
#endif /* SRC_TEXTUREMANAGER_H_ */