The game has enemies in it now, but the player still can't shoot at them. Let's create some rockets so that these can be launched from the player's bazooka by going through the following steps:
- In the project, create a new class called Rocket. As you can see from the following code block, the Rocket.h class is very similar to the Enemy.h class:
#pragma once #include "SFML-2.5.1\include\SFML\Graphics.hpp" class Rocket { public: Rocket(); ~Rocket(); void init(std::string textureName, sf::Vector2f position,
float_speed); void update(float dt); sf::Sprite getSprite(); private: sf::Texture m_texture; sf::Sprite m_sprite; sf::Vector2f m_position; float m_speed; };
The public section contains the init, update, and getSprite functions. The init function takes in the name of...