void Gun::fire(const glm::vec2& direction, const glm::vec2& position, std::vector<Bullet>& bulltes){ static std::mt19937 randomEngine(time(nullptr)); std::uniform_real_distribution<float> randRotate(-_spread, _spread); for (int i = 0; i < _bulletPerShot;i++){ bulltes.emplace_back(position, glm::rotate(direction,randRotate(randomEngine)), _buletDamage, _bulletSpeed); } }
void Gun::fire(const glm::vec2& direction, const glm::vec2& position, std::vector<Bullet>& bullets) { static std::mt19937 randomEngine(time(nullptr)); // For offsetting the accuracy std::uniform_real_distribution<float> randRotate(-_spread, _spread); m_fireEffect.play(); for (int i = 0; i < _bulletsPerShot; i++) { // Add a new bullet bullets.emplace_back(position - glm::vec2(BULLET_RADIUS), glm::rotate(direction, randRotate(randomEngine)), _bulletDamage, _bulletSpeed); } }