struct.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef STRUCT_H
  2. #define STRUCT_H
  3. #include "stdlib.h"
  4. //constants
  5. #define FPS 60
  6. #define FRAME_TIME 1/FPS
  7. #define PI 3.14159265
  8. #define SIN_60 0.866025404
  9. #define COS_60 0.5
  10. #define true 1
  11. #define false 0
  12. #define bool unsigned char
  13. //macros
  14. #define abs(x) x>0 ? x : -x
  15. typedef enum {PATTERN} Pattern_Enum;
  16. typedef struct Camera Camera;
  17. typedef struct Wall Wall;
  18. typedef struct Line Line;
  19. typedef struct Level Level;
  20. typedef struct Game_Data Game_Data;
  21. typedef enum {GAME, MENU, TITLE, GAME_OVER} State;
  22. struct Level{
  23. //for the level generation
  24. Pattern_Enum available_patterns[32][32];
  25. int nb_patterns;
  26. //for the camera rotation
  27. int change_interval; //5 seconds most of the time, but who knows...
  28. int change_precision; //to add a bit of randomness to the intervals
  29. float change_probability; //sometimes, there can be no change at all
  30. float max_speed;
  31. float min_speed;
  32. float fast_spin_probability; //very low, there sometimes is a slightly faster spin for one second, then a normal spin. This is the number that allow us to generate it
  33. };
  34. //the camera is defined by its center
  35. // ! and not by its upper left corner !
  36. //and an angle
  37. struct Camera{
  38. int cX;
  39. int cY;
  40. int angle;
  41. unsigned float zoom;
  42. float speed;
  43. };
  44. //a simple obstacle structure
  45. //d is the distance from the lowest face of the trapeze to the center of the screen
  46. //h is the thickness of the wall
  47. //line indicates the line that contains this obstacle
  48. //id is self explanatory
  49. //nxt is used by the linked list
  50. struct Wall{
  51. float d;
  52. int h;
  53. int id;
  54. int line;
  55. Wall *nxt;
  56. };
  57. struct Game_Data{
  58. unsigned int start_time;
  59. unsigned int last_time;
  60. unsigned int current_time;
  61. unsigned int player_angle;
  62. Wall *list;
  63. Level *level;
  64. Camera cam;
  65. };
  66. #endif