-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBorder.cpp
98 lines (90 loc) · 1.94 KB
/
Border.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once
#include <SFML/Graphics.hpp>
#include <stdio.h>
#include "HModules.hpp"
#include "constants.hpp"
namespace HexLab
{
class Border
{
public:
Type type;
double size = 1;
States state = undefined;
sf::Vector2f format;
sf::RectangleShape border;
void RotateRect()
{
switch(this->type)
{
case Top:
this->border.rotate(0);
break;
case TopLeft:
this->border.rotate(300);
break;
case TopRight:
this->border.rotate(60);
break;
case Bottom:
this->border.rotate(180);
break;
case BottomLeft:
this->border.rotate(240);
break;
case BottomRight:
this->border.rotate(120);
break;
case Last:
break;
}
}
void PosRect()
{
//offset to middle
switch (this->type)
{
case Top:
this->border.setPosition(this->size * -0.5, this->size * -0.8660254037844);
break;
case TopLeft:
this->border.setPosition(this->size * -1, 0);
break;
case TopRight:
this->border.setPosition(this->size * 0.5, this->size * -0.8660254037844);
break;
case Bottom:
this->border.setPosition(this->size * 0.5, this->size * 0.8660254037844);
break;
case BottomLeft:
this->border.setPosition(this->size * -0.5, this->size * 0.8660254037844);
break;
case BottomRight:
this->border.setPosition(this->size, 0);
break;
default:
this->border.setPosition(this->size * 2, this->size * 2);
break;
}
}
void setFormat()
{
this->format = sf::Vector2f(1 * this->size, 0.05 * this->size);
}
void Init(int type, double size, States state, Point2 position = Default)
{
this->type = converter::ToType(type);
this->size = size;
this->state = state;
setFormat();
border = sf::RectangleShape(this->format);
PosRect();
RotateRect();
this->border.move(position.x, position.y);
}
void move (sf::Vector2f vec)
{
this->border.move(vec);
}
};
};