2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

86 wiersze
1.8 KiB

  1. #ifndef IZ_VIDEO_H
  2. #define IZ_VIDEO_H
  3. #include <stdio.h>
  4. #include "minIni.h"
  5. #include "SDL_render.h"
  6. #include <SDL_image.h>
  7. #include "../../../net/IZ_net_client.h"
  8. #include "../../../config/IZ_config.h"
  9. #include "../../../common/IZ_common.h"
  10. #include "../../input/IZ_input.h"
  11. #define MAX_ACTIVE_SPRITES 512u
  12. typedef enum {
  13. // eyecandy, e.g. sparks
  14. IZ_VIDEO_SPRITE_PRIORITY_LOWEST,
  15. // bottom backgrounds
  16. IZ_VIDEO_SPRITE_PRIORITY_LOWER,
  17. // top backgrounds
  18. IZ_VIDEO_SPRITE_PRIORITY_LOW,
  19. // projectiles
  20. IZ_VIDEO_SPRITE_PRIORITY_MEDIUM,
  21. // foreground objects
  22. IZ_VIDEO_SPRITE_PRIORITY_HIGH,
  23. // pickups
  24. IZ_VIDEO_SPRITE_PRIORITY_HIGHER,
  25. // player, enemies, weapons
  26. IZ_VIDEO_SPRITE_PRIORITY_HIGHEST,
  27. } IZ_VideoSpritePriority;
  28. typedef struct {
  29. SDL_Texture* texture;
  30. f32 original_width;
  31. f32 original_height;
  32. } IZ_LoadedSprite;
  33. // TODO properly define sprites
  34. typedef struct {
  35. SDL_Texture* texture;
  36. f32 scale_factor;
  37. f32 rotate_degrees;
  38. } IZ_Sprite;
  39. typedef struct {
  40. u16 width;
  41. u16 height;
  42. u8 max_fps;
  43. } IZ_VideoConfig;
  44. typedef struct {
  45. void* user_data;
  46. IZ_VideoConfig config;
  47. u64 last_update_at;
  48. SDL_Window* window;
  49. SDL_Renderer* renderer;
  50. IZ_Sprite* active_sprites[MAX_ACTIVE_SPRITES];
  51. } IZ_VideoState;
  52. static const IZ_VideoState IZ_VIDEO_DEFAULT_STATE = {
  53. .user_data = NULL,
  54. .config = {
  55. .width = 320u,
  56. .height = 240u,
  57. .max_fps = 30u,
  58. },
  59. .last_update_at = 0,
  60. .renderer = NULL,
  61. .window = NULL,
  62. .active_sprites = {},
  63. };
  64. IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState*, void*, const char*, u8, const char*[]);
  65. IZ_ProcedureResult IZ_VideoSaveConfig(IZ_VideoState*, const char*);
  66. // TODO implement
  67. void IZ_VideoLoadTexture(IZ_VideoState*, const char*, const char*, IZ_LoadedSprite*);
  68. void IZ_VideoTeardownTexture(IZ_LoadedSprite*);
  69. void IZ_VideoTeardown(IZ_VideoState*);
  70. #endif