FZ_structs.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef FZ_STRUCTS
  2. #define FZ_STRUCTS
  3. #include <stdint.h>
  4. #include <SDL2/SDL.h>
  5. typedef struct {
  6. double x, y;
  7. } FZ_vector_2;
  8. enum {
  9. FZ_SHAPE_IS_STATIC = 1 << 0,
  10. FZ_SHAPE_IS_COLLIDING = 1 << 1,
  11. };
  12. typedef struct {
  13. FZ_vector_2* points;
  14. FZ_vector_2* transformed_points;
  15. uint16_t point_count;
  16. FZ_vector_2 scale;
  17. FZ_vector_2 position;
  18. FZ_vector_2 velocity;
  19. double angle;
  20. double angular_veclocity;
  21. double mass;
  22. double moment_of_intertia;
  23. void (*tick_transform_function)(FZ_vector_2 position, double angle);
  24. void (*tick_points_function)(FZ_vector_2* points, uint16_t point_count);
  25. uint16_t flags;
  26. } FZ_shape;
  27. typedef struct {
  28. double penetration;
  29. FZ_vector_2 contact_point;
  30. int reference_line_index;
  31. int incident_line_index;
  32. FZ_shape* reference_shape;
  33. FZ_shape* incident_shape;
  34. } projected_points_data;
  35. typedef struct {
  36. FZ_shape** shapes;
  37. uint16_t shape_count;
  38. FZ_vector_2 gravity;
  39. } FZ_scene;
  40. typedef struct {
  41. uint16_t width, height, half_width, half_height;
  42. SDL_Window* window;
  43. SDL_Renderer* renderer;
  44. SDL_Texture* frame_buffer_texture;
  45. uint32_t* frame_buffer;
  46. } FZ_SDL;
  47. typedef struct {
  48. uint16_t flags;
  49. FZ_SDL sdl;
  50. uint8_t is_running;
  51. } FZ_context;
  52. #endif