sprite.h 580 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _DD_SPRITE_H_
  2. #define _DD_SPRITE_H_
  3. #include "SDL2/SDL.h"
  4. #include "sdl_helper.h"
  5. struct dd_sprite {
  6. // interface
  7. int x, y;
  8. int w, h;
  9. SDL_Texture *texture;
  10. SDL_Rect rect;
  11. void (*load)(struct dd_sprite*, const char*);
  12. void (*draw)(struct dd_sprite*);
  13. int (*collide)(struct dd_sprite*, struct dd_sprite*);
  14. };
  15. struct dd_sprite *dd_sprite_create();
  16. void dd_sprite_init(struct dd_sprite *);
  17. void dd_sprite_load(struct dd_sprite *, const char *);
  18. void dd_sprite_draw(struct dd_sprite *);
  19. int dd_sprite_collide(struct dd_sprite *, struct dd_sprite *);
  20. #endif