-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorUtility.cpp
More file actions
48 lines (46 loc) · 1.05 KB
/
VectorUtility.cpp
File metadata and controls
48 lines (46 loc) · 1.05 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
#include "VectorUtility.hpp"
#ifdef _DEBUG
#include <iostream>
#endif
namespace StrategyGoo
{
bool ComparePosition( sf::Vector2f first, sf::Vector2f second ) {
return ( abs( first.x - second.x ) < 1 ) &&
( abs( first.y - second.y ) < 1 );
}
size_t ClosestFacing( sf::Vector2i vector )
{
sf::Vector2i unitVector = ToUnitVector< int >{ vector };
for( size_t i = 0; i < AMOUNT_OF_DIRECTIONS_CONSTANT; ++i ) {
if( DIRECTION_VECTOR_FACINGS_CONSTANT[ i ] == unitVector )
return i;
}
return 0;
}
void PrintRect( sf::FloatRect rect )
{
#ifdef _DEBUG
std::cout << rect.left << ", " << rect.top <<
", " << rect.width << ", " << rect.height << "\n";
#endif
}
void PrintRect( sf::IntRect rect )
{
#ifdef _DEBUG
std::cout << rect.left << ", " << rect.top <<
", " << rect.width << ", " << rect.height << "\n";
#endif
}
void PrintVect( sf::Vector2f v )
{
#ifdef _DEBUG
std::cout << v.x << ", " << v.y << "\n";
#endif
}
void PrintVect( sf::Vector2i v )
{
#ifdef _DEBUG
std::cout << v.x << ", " << v.y << "\n";
#endif
}
}