1
General / how to detect if sprite is touching other sprite w/ specific texture
« on: October 16, 2021, 01:16:01 am »
i got this goin on
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
if (grid[j] == 2)
{
Sprite sprite;
FloatRect Entity::dirtTexture() {
return sprite.GetPosition().x,
sprite.GetPosition().y,
sprite.GetSize().x,
sprite.GetSize().y,
}
bool Entity::Collides( *) {
return myRect().Intersects(e->myRect());
};
if ()
{
sprite.setTexture(grassTexture);
}
else
{
sprite.setTexture(dirtTexture);
}
sprite.setPosition(i * 218, j * 216);
window.draw(sprite);
}
}
cout << "\n";
i dont know whats wrong can you guys help?
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
if (grid[j] == 2)
{
Sprite sprite;
FloatRect Entity::dirtTexture() {
return sprite.GetPosition().x,
sprite.GetPosition().y,
sprite.GetSize().x,
sprite.GetSize().y,
}
bool Entity::Collides( *) {
return myRect().Intersects(e->myRect());
};
if ()
{
sprite.setTexture(grassTexture);
}
else
{
sprite.setTexture(dirtTexture);
}
sprite.setPosition(i * 218, j * 216);
window.draw(sprite);
}
}
cout << "\n";
i dont know whats wrong can you guys help?