Add option to show coliders (only rect so far)

This commit is contained in:
2020-08-21 18:32:15 +02:00
parent 9db93cd72c
commit 77d5f9a8cb
3 changed files with 104 additions and 35 deletions
+35
View File
@@ -107,3 +107,38 @@ bool SDLPP::Circle::colidesWith(const SDLPP::CollisionPolygon &other) const {
int distancesquared = (pointx - centerx)*(pointx - centerx) + (pointy - centery)*(pointy-centery);
return distancesquared <= rad*rad;
}
int SDLPP::hex2num(char c) {
if(c <= '9')
return c - '0';
switch(c) {
case 'a':
case 'A':
return 10;
case 'b':
case 'B':
return 11;
case 'c':
case 'C':
return 12;
case 'd':
case 'D':
return 13;
case 'e':
case 'E':
return 14;
default:
return 15;
}
}
std::tuple<int, int, int> SDLPP::getColorsHEX(const std::string &color) {
int red = 0, green = 0, blue = 0;
const char *color_ptr = color.c_str();
if(color_ptr[0] == '#')
color_ptr++;
red = hex2num(color_ptr[0])*16 + hex2num(color_ptr[1]);
green = hex2num(color_ptr[2])*16 + hex2num(color_ptr[3]);
blue = hex2num(color_ptr[4])*16 + hex2num(color_ptr[5]);
return {red, green, blue};
}