Añadidos enemigos volteados verticalmente
This commit is contained in:
@@ -49,6 +49,8 @@ MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vel
|
||||
|
||||
// Establece el tipo de volteado
|
||||
currentFlip = SDL_FLIP_NONE;
|
||||
currentFlipH = false;
|
||||
currentFlipV = false;
|
||||
};
|
||||
|
||||
// Reinicia todas las variables
|
||||
@@ -305,16 +307,56 @@ void MovingSprite::switchRotate()
|
||||
rotateAmount *= -1;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void MovingSprite::setFlip(SDL_RendererFlip flip)
|
||||
// Actualiza el valor de la variable
|
||||
void MovingSprite::updateCurrentFlip()
|
||||
{
|
||||
currentFlip = flip;
|
||||
if (currentFlipH && currentFlipV)
|
||||
{
|
||||
currentFlip = SDL_RendererFlip(SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL);
|
||||
}
|
||||
|
||||
else if (currentFlipH && !currentFlipV)
|
||||
{
|
||||
currentFlip = SDL_FLIP_HORIZONTAL;
|
||||
}
|
||||
|
||||
else if (!currentFlipH && currentFlipV)
|
||||
{
|
||||
currentFlip = SDL_FLIP_VERTICAL;
|
||||
}
|
||||
|
||||
else if (!currentFlipH && !currentFlipV)
|
||||
{
|
||||
currentFlip = SDL_FLIP_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void MovingSprite::setFlipH(bool flip)
|
||||
{
|
||||
currentFlipH = flip;
|
||||
updateCurrentFlip();
|
||||
}
|
||||
|
||||
// Gira el sprite horizontalmente
|
||||
void MovingSprite::flip()
|
||||
void MovingSprite::flipH()
|
||||
{
|
||||
currentFlip = (currentFlip == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL;
|
||||
currentFlipH = !currentFlipH;
|
||||
updateCurrentFlip();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void MovingSprite::setFlipV(bool flip)
|
||||
{
|
||||
currentFlipV = flip;
|
||||
updateCurrentFlip();
|
||||
}
|
||||
|
||||
// Voltea el sprite verticalmente
|
||||
void MovingSprite::flipV()
|
||||
{
|
||||
currentFlipV = !currentFlipV;
|
||||
updateCurrentFlip();
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
@@ -323,6 +365,18 @@ SDL_RendererFlip MovingSprite::getFlip()
|
||||
return currentFlip;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool MovingSprite::getFlipH()
|
||||
{
|
||||
return currentFlipH;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool MovingSprite::getFlipV()
|
||||
{
|
||||
return currentFlipV;
|
||||
}
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect MovingSprite::getRect()
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@ protected:
|
||||
double rotateAmount; // Cantidad de grados a girar en cada iteración
|
||||
int counter; // Contador interno
|
||||
SDL_RendererFlip currentFlip; // Indica como se voltea el sprite
|
||||
bool currentFlipV;
|
||||
bool currentFlipH;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
@@ -139,15 +141,30 @@ public:
|
||||
// Cambia el sentido de la rotación
|
||||
void switchRotate();
|
||||
|
||||
// Actualiza el valor de la variable
|
||||
void updateCurrentFlip();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setFlip(SDL_RendererFlip flip);
|
||||
void setFlipH(bool flip);
|
||||
|
||||
// Gira el sprite horizontalmente
|
||||
void flip();
|
||||
void flipH();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setFlipV(bool flip);
|
||||
|
||||
// Voltea el sprite verticalmente
|
||||
void flipV();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
SDL_RendererFlip getFlip();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool getFlipH();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool getFlipV();
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getRect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user