Add option to show coliders (only rect so far)
This commit is contained in:
@@ -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};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user