Argentum Online - Cliente
sdl_animated_sprite.h
1 #ifndef __SDL_SPRITE_H
2 #define __SDL_SPRITE_H
3 
4 #include <functional>
5 
6 #include "../../../include/nlohmann/json.hpp"
7 #include "sdl_texture.h"
8 #include "sdl_timer.h"
9 
14 class SDLSprite {
15  private:
16  std::reference_wrapper<SDLTexture> texture;
17  int nframes;
18  int frame_width;
19  int frame_height;
20  int current_frame;
21  int base_x;
22  int base_y;
23  SDLTimer timer;
24  uint32_t time_between_frames;
25  bool done;
26 
27  public:
40  SDLSprite(SDLTexture &texture, int nframes, int fps, int base_x, int base_y,
41  int w, int h);
42 
52  SDLSprite(SDLTexture &texture, nlohmann::json sprite_info);
53 
54  ~SDLSprite();
55 
61  SDLSprite(const SDLSprite &other);
62  SDLSprite &operator=(const SDLSprite &other);
63 
64  /* Constructor y asginador por movimiento. */
65  SDLSprite(SDLSprite &&other);
66  SDLSprite &operator=(SDLSprite &&other);
67 
78  void render(SDL_Rect dest);
79 
85  int get_frame_width();
86 
92  int get_frame_height();
93 
100  bool is_done();
101 };
102 #endif
SDLSprite::SDLSprite
SDLSprite(SDLTexture &texture, int nframes, int fps, int base_x, int base_y, int w, int h)
Construye un objeto SDLSprite.
Definition: sdl_animated_sprite.cpp:8
SDLSprite::is_done
bool is_done()
Indica si se reprodujo la animacion al menos una vez.
Definition: sdl_animated_sprite.cpp:103
SDLSprite::get_frame_height
int get_frame_height()
Devuelve el alto de un cuadro del sprite.
Definition: sdl_animated_sprite.cpp:101
SDLSprite::get_frame_width
int get_frame_width()
Devuelve el ancho de un cuadro del sprite.
Definition: sdl_animated_sprite.cpp:100
SDLTimer
Timer basado en la cuenta de SDL.
Definition: sdl_timer.h:9
SDLTexture
Objeto de textura de SDL.
Definition: sdl_texture.h:13
SDLSprite::render
void render(SDL_Rect dest)
Renderiza la sprite en pantalla, segun el cuadro actual.
Definition: sdl_animated_sprite.cpp:79
SDLSprite
Sprite animada de SDL.
Definition: sdl_animated_sprite.h:14