sf::Vector2f buttonCheck() {
sf::Vector2f key = sf::Vector2f(0, 0);
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
key.x -= 1;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
key.x += 1;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {
key.y -= 1;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {
key.y += 1;
}
return key;
}
int yReset(int yPos) {
// Yup, literally nothing
return yPos;
}
charSprite.move(0.25 * keyCheck.x , 0.25 * keyCheck.y);
charSprite.setPosition(charSprite.getPosition().x, yReset(charSprite.getPosition().y )
//Where keycheck is the return of the button check function.
);
However, if I remove the yReset, I can move down.
Why?
Any help is appreciated.