SGD::Rectangle AnimationSystem::GetRect(const AnimationTimestamp& _info, float _PosX, float _PosY, SGD::Size _scale) { SGD::Point pt = { (float)_PosX, (float)_PosY }; SGD::Rectangle crect = m_Loaded[_info.GetCurrAnim()].GetFrames()[_info.GetCurrFrame()].GetCollisionRect(); float x = crect.left + pt.x; float y = crect.top + pt.y; float width = (crect.left + pt.x) + crect.ComputeWidth() * _scale.width; float height = (crect.top + pt.y) + crect.ComputeHeight() * _scale.height; return SGD::Rectangle{ x, y, width, height }; }
void AnimationSystem::Render(AnimationTimestamp& _info, float _PosX, float _PosY, SGD::Size _scale, float rotation) { SGD::Point temppt = SGD::Point((float)_PosX, (float)_PosY); SGD::Point pt = m_Loaded[_info.GetCurrAnim().c_str()].GetFrames()[_info.GetCurrFrame()].GetAnchorPt(); SGD::Rectangle crect = m_Loaded[_info.GetCurrAnim()].GetFrames()[_info.GetCurrFrame()].GetCollisionRect(); //GM->DrawRectangle(GetRect(_info, _PosX, _PosY), SGD::Color(255, 0, 0)); SGD::Rectangle rect = m_Loaded[_info.GetCurrAnim().c_str()].GetFrames()[_info.GetCurrFrame()].GetDrawFrame(); temppt.x += rect.left * _scale.width; temppt.y += rect.top * _scale.height; if (_info.GetOwner()->GetType() == Actor::ENT_FATHER) GM->DrawTextureSection(m_Imgs[0], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_SON) GM->DrawTextureSection(m_Imgs[1], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_CANNONBALL) GM->DrawTextureSection(m_Imgs[2], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_ARROW) GM->DrawTextureSection(m_Imgs[3], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_SWORDSMAN) GM->DrawTextureSection(m_Imgs[4], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_AUTO_LOCK_DOOR) GM->DrawTextureSection(m_Imgs[5], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_BOWMAN) GM->DrawTextureSection(m_Imgs[6], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_SMASHING_COLUMNS) GM->DrawTextureSection(m_Imgs[7], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_FALLING_ROCK) GM->DrawTextureSection(m_Imgs[8], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_ROLLING_BOULDER) GM->DrawTextureSection(m_Imgs[9], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, rotation, { 32, 32 }, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_POPUPSPIKES) GM->DrawTextureSection(m_Imgs[10], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_LEVERS) GM->DrawTextureSection(m_Imgs[11], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); else if (_info.GetOwner()->GetType() == Actor::ENT_PLATES) GM->DrawTextureSection(m_Imgs[12], temppt, SGD::Rectangle{ rect.left + pt.x, rect.top + pt.y, (rect.left + pt.x) + rect.ComputeWidth(), (rect.top + pt.y) + rect.ComputeHeight() }, 0.0f, {}, {}, _scale); }