59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "sprite.h"
|
|
#include "const.h"
|
|
#include <iostream>
|
|
|
|
#ifndef SPRITEANIMATED_H
|
|
#define SPRITEANIMATED_H
|
|
|
|
// Clase spriteAnimated
|
|
class SpriteAnimated : public Sprite
|
|
{
|
|
public:
|
|
// Constructor
|
|
SpriteAnimated();
|
|
|
|
// Iniciador
|
|
void init();
|
|
|
|
// Calcula el frame correspondiente a la animación
|
|
void animate(int index);
|
|
|
|
// Establece el frame actual de la animación
|
|
void setCurrentFrame(Uint8 num);
|
|
|
|
// Establece el numero de frames de la animacion
|
|
void setAnimationCounter(Uint16 num);
|
|
|
|
// Establece el rectangulo para un frame de una animación
|
|
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
|
|
|
|
// Establece la velocidad de una animación
|
|
void setAnimationSpeed(Uint8 index, Uint8 speed);
|
|
|
|
// Establece el numero de frames de una animación
|
|
void setAnimationNumFrames(Uint8 index, Uint8 num);
|
|
|
|
// Devuelve el rectangulo de una animación y frame concreto
|
|
SDL_Rect getAnimationClip(Uint8 index_animation, Uint8 index_frame);
|
|
|
|
private:
|
|
struct sAnimation
|
|
{
|
|
SDL_Rect frames[20];
|
|
Uint8 numFrames;
|
|
Uint8 speed;
|
|
};
|
|
|
|
// Vector con las diferentes animaciones y los diferentes frames de cada animación
|
|
sAnimation mAnimation[20];
|
|
|
|
// Frame actual
|
|
Uint8 mCurrentFrame;
|
|
|
|
// Contador para las animaciones
|
|
Uint16 mAnimationCounter;
|
|
};
|
|
|
|
#endif |