2dkg/2dkg_zad5/2dgk_zad5/KTile.cpp

34 lines
683 B
C++
Raw Permalink Normal View History

2022-01-20 08:52:14 +01:00
#include "KTile.h"
#include <SDL_render.h>
#include "Constants.h"
#include "KTexture.h"
namespace KapitanGame {
int KTile::GetType() const {
return static_cast<int>(Type);
}
SDL_Rect KTile::GetBox() const {
return Box;
}
KTile::KTile(const int x, const int y, const TileType tileType) {
//Get the offsets
Box.x = x;
Box.y = y;
Box.w = Constants::TILE_WIDTH;
Box.h = Constants::TILE_HEIGHT;
//Get the tile type
Type = tileType;
}
void KTile::Render(SDL_Renderer* renderer, KTexture tileTextures[], const SDL_Rect& camera, const float scale) const {
tileTextures[GetType()].Render(renderer, Box.x - camera.x, Box.y - camera.y, nullptr, scale);
}
}