#include "KDrawable.h" #include "KCamera.h" namespace KapitanGame { std::atomic KDrawable::IdCounter{ 0 }; KDrawable::KDrawable(const KVector2D& position, const KTexture& texture, SDL_Rect* tileClip, const SDL_RendererFlip flip) : Id(++IdCounter), Position(position), Texture(texture), TileClip(tileClip), Flip(flip) { } void KDrawable::Render(SDL_Renderer* renderer, const KCamera& camera, const float parallaxFactor) const { if (TileClip != nullptr) Texture.RenderEx(renderer, Position.X - Constants::TILE_WIDTH / 2.f - camera.GetViewport().x * parallaxFactor, Position.Y - Constants::TILE_HEIGHT / 2.f - camera.GetViewport().y, 0, TileClip, camera.GetScale(), Flip); // NOLINT(clang-diagnostic-implicit-int-float-conversion, bugprone-narrowing-conversions, cppcoreguidelines-narrowing-conversions) else Texture.Render(renderer, Position.X - Texture.GetWidth() / 2.f - camera.GetViewport().x * parallaxFactor, Position.Y - Texture.GetHeight() / 2.f - camera.GetViewport().y, nullptr, camera.GetScale()); // NOLINT(clang-diagnostic-implicit-int-float-conversion, bugprone-narrowing-conversions, cppcoreguidelines-narrowing-conversions) } KVector2D KDrawable::GetPosition() const { return Position; } }