So, i decided to create a collision detection function in my game and i put it into the class of enemies. Then i put it to "enemy.cpp" and i used "this" pointer. The code:
if(((this->sprite.getPosition().y + this->sprite.getTextureRect().height) >= blocklist[i].sprite.getPosition().y) &&
(this->sprite.getPosition().y <= blocklist[i].sprite.getPosition().y))
This gives me SIGSEGV segmentation error. I can't find what could be the problem in this line, here is the enemyclass for reference.
class enemyclass
{
public:
sf::Sprite sprite;
sf::Sprite bubble;
//PROPERTIES
float xspeed, yspeed;
int x, y;
float health;
bool colR, colL, colU, colD;
int skin;
void detectCollisions(int blocksize);
};
and the blockclass that i made a vector of to use as a list of enemies:
class blockclass
{
public:
sf::Sprite sprite;
int x, y;
};
I would be very thankfull for an answer since i can't find out what's wrong.