struct.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef STRUCT_H
  2. #define STRUCT_H
  3. #include "stdlib.h" //FUCK IT !
  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 {TITLE, MENU, GAME, GAME_OVER} State;
  16. typedef enum {PATTERN}Pattern_Enum;
  17. typedef struct Camera Camera;
  18. typedef struct Wall Wall;
  19. typedef struct Line Line;
  20. typedef struct Level Level;
  21. typedef struct Game_Data Game_Data;
  22. struct Level{
  23. //for the level generation
  24. Pattern_Enum available_patterns[64][64];
  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, sometimes there 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. float speed;
  42. };
  43. //a simple obstacle structure
  44. //d is the distance from the lowest face of the trapeze to the center of the screen
  45. //h is the thickness of the wall
  46. //line indicates the line that contains this obstacle
  47. //id is self explanatory
  48. //nxt is used by the linked list
  49. struct Wall{
  50. float d;
  51. int h;
  52. int id;
  53. int line;
  54. Wall *nxt;
  55. };
  56. struct Game_Data{
  57. Level *level;
  58. //linked list of obstacles
  59. Wall *list;
  60. //oriented angle between the player and the horizontal axis
  61. unsigned int player_angle;
  62. unsigned int start_time; //1 tick == 1/128 second
  63. unsigned int last_time;
  64. unsigned int current_time;
  65. Camera cam;
  66. };
  67. #endif