-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Asteroid.h
36 lines (26 loc) · 956 Bytes
/
Asteroid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include "Entity.h"
#include <type_traits>
constexpr float ASTEROID_W = 90.0f;
constexpr float ASTEROID_H = 80.0f;
constexpr float ASTEROID_SPIN = 25.0f;
constexpr float ASTEROID_SPEED = 280.0f;
constexpr float ASTEROID_SPAWN_TIME = 3.0f;
constexpr float ASTEROID_HIT_TIME = 3.0f;
constexpr float ASTEROID_MAX_GEN = 1.0f;
class Asteroid : public Entity {
public:
Asteroid(sf::Vector2f direction = Asteroid::getRandomDirection(), sf::Vector2f position = Asteroid::getRandomPosition());
void update(float deltaTime) override;
void render(sf::RenderWindow& window) override;
const sf::VertexArray& getVertexArray() const;
// moves asteroids in random directions
static sf::Vector2f getRandomDirection();
// spawns asteroids at random positions
static sf::Vector2f getRandomPosition();
float getLife() { return life; }
private:
sf::VertexArray array;
sf::Vector2f direction;
float life;
};