moving_sprite.cpp: afegits nous metodes per controlar la rotació

This commit is contained in:
2025-09-30 13:47:48 +02:00
parent 267d9647e0
commit 6e56a6fd79
2 changed files with 15 additions and 0 deletions

View File

@@ -90,6 +90,19 @@ void MovingSprite::setRotate(bool enable) {
rotate_.enabled = enable;
}
// Habilita la rotación y establece el centro en el centro del sprite
void MovingSprite::startRotate() {
rotate_.enabled = true;
rotate_.center.x = pos_.w / 2.0F;
rotate_.center.y = pos_.h / 2.0F;
}
// Detiene la rotación y resetea el ángulo a cero
void MovingSprite::stopRotate() {
rotate_.enabled = false;
rotate_.angle = 0.0;
}
// Establece la posición y_ el tamaño del objeto
void MovingSprite::setPos(SDL_FRect rect) {
x_ = rect.x;