Reticadas las classes de la carpeta utils

This commit is contained in:
2022-10-18 19:48:13 +02:00
parent 5c68006cb5
commit 07a9ba5b87
15 changed files with 846 additions and 504 deletions
+16 -16
View File
@@ -1,4 +1,4 @@
#include "../const.h"
#include "movingsprite.h"
// Constructor
@@ -45,7 +45,7 @@ MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vel
spriteClip = {0, 0, w, h};
// Establece el centro de rotación
center = {0, 0};
center = nullptr;
// Establece el tipo de volteado
currentFlip = SDL_FLIP_NONE;
@@ -73,7 +73,7 @@ void MovingSprite::clear()
angle = 0.0; // Angulo para dibujarlo
rotateEnabled = false; // Indica si ha de rotar
center = {0, 0}; // Centro de rotación
center = nullptr; // Centro de rotación
rotateSpeed = 0; // Velocidad de giro
rotateAmount = 0.0; // Cantidad de grados a girar en cada iteración
counter = 0; // Contador interno
@@ -101,7 +101,9 @@ void MovingSprite::move()
void MovingSprite::render()
{
if (enabled)
texture->render(renderer, (int)x, (int)y, &spriteClip, zoomW, zoomH, angle, &center, currentFlip);
{
texture->render(renderer, (int)x, (int)y, &spriteClip, zoomW, zoomH, angle, center, currentFlip);
}
}
// Obtiene el valor de la variable
@@ -158,8 +160,8 @@ double MovingSprite::getAngle()
return angle;
}
// Establece la posición del objeto
void MovingSprite::setPos(SDL_Rect rect)
// Establece la posición y el tamaño del objeto
void MovingSprite::setRect(SDL_Rect rect)
{
x = (float)rect.x;
y = (float)rect.y;
@@ -267,7 +269,14 @@ void MovingSprite::setRotate(bool value)
// Establece el valor de la variable
void MovingSprite::setRotateSpeed(int value)
{
rotateSpeed = value;
if (value < 1)
{
rotateSpeed = 1;
}
else
{
rotateSpeed = value;
}
}
// Establece el valor de la variable
@@ -326,15 +335,6 @@ SDL_Rect MovingSprite::getRect()
return rect;
}
// Establece los valores de posición y tamaño del sprite
void MovingSprite::setRect(SDL_Rect rect)
{
x = (float)rect.x;
y = (float)rect.y;
w = rect.w;
h = rect.h;
}
// Deshace el último movimiento
void MovingSprite::undoMove()
{