예제 #1
0
파일: Gun.cpp 프로젝트: nerososft/zombieWar
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);
	}
}
예제 #2
0
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);
    }   

}