2dkg/2dgk_7/2dgk_7/KTile.cpp
2021-12-04 11:24:34 +01:00

34 lines
683 B
C++

#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);
}
}