#include "pch.h" #include "Ladder.h" #include "Tile.h" int Ladder::m_Count{ 0 }; Texture* Ladder::m_pTexture{ nullptr }; Ladder::Ladder(int x, int y, bool isPlatform) : m_Hitbox{ x * Tile::m_Size, y * Tile::m_Size, 64, 64 } , m_isPlatform{ isPlatform } , m_X{ x } , m_Y{ y } { if (m_Count == 0) { m_pTexture = new Texture{ "Resources/Sprites/ladder.png" }; } m_Count++; } Ladder::~Ladder() { m_Count--; if (m_Count == 0) { delete m_pTexture; m_pTexture = nullptr; } } void Ladder::Draw() const { if (!m_isPlatform) { m_pTexture->Draw(m_Hitbox, Rectf{ 0, 0, 64, 64 }); } else { m_pTexture->Draw(m_Hitbox, Rectf{ 64, 0, 64, 64 }); } } Rectf Ladder::GetThinnerHitbox() { Rectf thinnerHitbox{ m_Hitbox.left + (m_Hitbox.width / 2 - m_Hitbox.width / 4 / 2), m_Hitbox.bottom, m_Hitbox.width / 4, m_Hitbox.height }; return thinnerHitbox; } Rectf& Ladder::GetHitbox() { return m_Hitbox; } int Ladder::GetX() const { return m_X; } int Ladder::GetY() const { return m_Y; }