First game engine I made
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sprite.c 1001B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <SDL2/SDL.h>
  4. #include <SDL2/SDL_image.h>
  5. #include "sprite.h"
  6. //WORK ON SPRITE HANDLER AND MAP HANDLER TOMORROW
  7. //TODO: work on physics file with collision and gravity. Let it calculate angles too, and *draw* debug angles n such with lines
  8. //TODO: make sprites dynamic? malloc. Scenegraph?
  9. int maxs;
  10. typedef struct Sprite{
  11. int priority;
  12. int type;
  13. float angle;
  14. float velx;
  15. float vely;
  16. float x;
  17. float y;
  18. SDL_Texture* spritesheet;
  19. int currentframe;
  20. };
  21. void setupspritehandler(SDL_Renderer* ren, int maxsprites){
  22. renderer = ren;
  23. maxs = maxsprites;
  24. }
  25. void destroyspritehandler(){
  26. int i;
  27. for(i = 0; i <= maxs; i++){//for deleting sprite textures;
  28. //SDL_DestroyTexture(
  29. }
  30. SDL_DestroyTexture(texture);
  31. printf("The double free error is just for the occasion where something isn't freed the first time. It is an acceptable error.\n");
  32. SDL_DestroyRenderer(renderer);
  33. }
  34. void addsprite(){
  35. }
  36. //void drawsprite(int x, int y){