-
Notifications
You must be signed in to change notification settings - Fork 1
/
Polygon.h
44 lines (32 loc) · 988 Bytes
/
Polygon.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
37
38
39
40
41
42
43
#pragma once
/*
A vector of Points (see Point class)
-Has SAT intersection detection (between two polygons)
*/
#include <SFML/Graphics.hpp>
#include "Point.h"
#include <vector>
class Polygon
{
public:
Polygon(): vertex(), side() {};
Polygon(const std::vector <Point>& points, const Point& cen);
Polygon(const std::vector <Point>& points);
~Polygon() {};
void setPoints(const std::vector <Point>& points, const Point& cen);
void setPoints(const std::vector <Point>& points);
void setCentre(const Point& cen);
void setCentre();
void sideSet();
Point centre;
std::vector <Point> vertex;
std::vector <Point> side;
// for convex polygon only
// SAT collision detection
// optimized for rectangle (this) and polygon (a) collision [for now]
bool intersects(const Polygon& a);
void draw(sf::RenderWindow* app); //for debugging purposes
// for implicit conversion from sf::FloatRect
Polygon(const sf::FloatRect &a);
Polygon& operator=(const sf::FloatRect &a);
};