mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 12:33:43 +00:00
36 lines
565 B
C++
36 lines
565 B
C++
#include "GameObject.h"
|
|
#include "TextureManager.h"
|
|
|
|
GameObject::GameObject(const char* texturesheet, int x, int y)
|
|
{
|
|
this->objTexture = TextureManager::get().loadTexture(texturesheet);
|
|
this->xPos = x;
|
|
this->yPos = y;
|
|
}
|
|
|
|
GameObject::~GameObject()
|
|
{
|
|
|
|
}
|
|
|
|
void GameObject::update()
|
|
{
|
|
xPos++;
|
|
yPos++;
|
|
|
|
srcRect.h = 32;
|
|
srcRect.w = 32;
|
|
srcRect.x = 0;
|
|
srcRect.y = 0;
|
|
|
|
destRect.h = srcRect.h *2;
|
|
destRect.w = srcRect.w *2;
|
|
destRect.x = xPos;
|
|
destRect.y = yPos;
|
|
}
|
|
|
|
void GameObject::render()
|
|
{
|
|
SDL_RenderCopy(Game::renderer, objTexture, &srcRect, &destRect);
|
|
}
|