// Draw the weapon fire when firing void Weapon::DrawWeaponFire() { if (m_weapon_fire == NULL) return; Point2i hand; ActiveCharacter().GetHandPosition(hand); Point2i hole(hand + hole_delta * Point2i(ActiveCharacter().GetDirection(),1)); if (ActiveCharacter().GetDirection() == DIRECTION_RIGHT) hole = hole - Point2i(0, m_weapon_fire->GetHeight()/2); else hole = hole + Point2i(0, m_weapon_fire->GetHeight()/2); Double dst = hand.Distance(hole); Double angle = hand.ComputeAngle(hole); angle += ActiveCharacter().GetFiringAngle(); if (ActiveCharacter().GetDirection() == DIRECTION_LEFT) angle -= PI; Point2i spr_pos = hand + Point2i(static_cast<int>(dst * cos(angle)), static_cast<int>(dst * sin(angle))); m_weapon_fire->SetRotation_HotSpot(Point2i(0,0)); m_weapon_fire->SetRotation_rad(ActiveCharacter().GetFiringAngle()); m_weapon_fire->Draw(spr_pos); }
const Point2i Weapon::GetGunHolePosition() const { Point2i pos; ActiveCharacter().GetHandPosition(pos); Point2i hole(pos + hole_delta * Point2i(ActiveCharacter().GetDirection(),1)); Double dst = pos.Distance(hole); Double angle = pos.ComputeAngle(hole); if (ActiveCharacter().GetDirection() == DIRECTION_RIGHT) angle += ActiveCharacter().GetFiringAngle(); else angle += ActiveCharacter().GetFiringAngle() - PI; return pos + Point2i(static_cast<int>(dst * cos(angle)), static_cast<int>(dst * sin(angle))); }