void TerrainDestructionScene::FireGrapeShot(int shotNumber) { if (m_networkManager.GetNumPeers() > 0) { glm::vec2 centrePos(m_cannon->GetPos().x, m_cannon->GetPos().y); // First ball. AddCircleNetwork(centrePos.x, centrePos.y, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x, m_cannonAim.y)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber)); // ID // Second. AddCircleNetwork(centrePos.x, centrePos.y + HALF_UNIT_SIZE / 2.0f, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x, m_cannonAim.y * 0.9)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber+1)); // ID // Third. AddCircleNetwork(centrePos.x + HALF_UNIT_SIZE / 2.0f, centrePos.y + HALF_UNIT_SIZE / 2.0f, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x * 0.9, m_cannonAim.y)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber+2)); // ID // Fourth AddCircleNetwork(centrePos.x + HALF_UNIT_SIZE / 2.0f, centrePos.y, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x * 0.9, m_cannonAim.y * 0.9)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber+3)); // ID } else { glm::vec2 centrePos(m_cannon->GetPos().x, m_cannon->GetPos().y); // First ball. AddCircle(centrePos.x, centrePos.y, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x, m_cannonAim.y)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber)); // ID // Second. AddCircle(centrePos.x, centrePos.y + HALF_UNIT_SIZE / 2.0f, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x, m_cannonAim.y * 0.9)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber+1)); // ID // Third. AddCircle(centrePos.x + HALF_UNIT_SIZE / 2.0f, centrePos.y + HALF_UNIT_SIZE / 2.0f, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x * 0.9, m_cannonAim.y)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber+2)); // ID // Fourth AddCircle(centrePos.x + HALF_UNIT_SIZE / 2.0f, centrePos.y, // StartPos HALF_UNIT_SIZE / 4.0f, // Radius glm::normalize(glm::vec2(m_cannonAim.x * 0.9, m_cannonAim.y * 0.9)) * m_cannonPower, // Vel. 1.0f, 0.9f, // Mass, Elast std::string("shot") + to_string(shotNumber+3)); // ID } }
void Box::write(QJsonObject &json) const { QString n=m_name; n.replace(QRegExp(".*::"),""); json["name"] = n; json["lazyNutType"] = m_lazyNutType; QPointF position = centrePos(); json["x"] = position.x(); json["y"] = position.y(); }