-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAlienShip.h
More file actions
50 lines (38 loc) · 1.2 KB
/
AlienShip.h
File metadata and controls
50 lines (38 loc) · 1.2 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Alien ship class
#ifndef ALIENSHIP
#define ALIENSHIP
#include "FarOut/FarOut.h"
#include <math.h>
const int NUMPOINTS = 30;
const sf::Vector2f DOMERADIUS(50.f, 20.f);
// Ellipse class modeled after https://www.sfml-dev.org/tutorials/2.0/graphics-shape.php
// For the dome of the Alien ship
class EllipseShape : public sf:: Shape {
public :
explicit EllipseShape(const sf::Vector2f& radius);
void setRadius(const sf::Vector2f& radius);
const sf::Vector2f& getRadius() const;
virtual std::size_t getPointCount() const;
virtual sf::Vector2f getPoint(std::size_t index) const;
private :
sf::Vector2f m_radius;
int pointCount;
};
class AlienShip : public GameObject {
public:
AlienShip();
void draw(sf::RenderTarget& target, sf::RenderStates states)const;
void update(sf::Time dt, sf::Vector2f shipPosition);
void update(sf::Time dt);
private:
float movementSpeed;
float distanceFromShip;
sf::Vector2f movement;
EllipseShape dome;
sf::VertexArray saucer;
sf::RectangleShape midline;
sf::ConvexShape hitbox;
void setAlienShipPoints(sf::ConvexShape * shape);
void setSaucerPoints(sf::VertexArray * shape);
};
#endif