struct.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #ifndef STRUCT_H
  2. #define STRUCT_H
  3. #include "stdlib.h"
  4. // constants
  5. #define FPS 20
  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 struct Camera Camera;
  16. typedef struct Wall Wall;
  17. typedef struct Line Line;
  18. typedef struct Level Level;
  19. typedef struct Line_Transition Line_Transition;
  20. typedef struct Game_Data Game_Data;
  21. typedef struct Pattern Pattern;
  22. typedef enum {GAME, MENU, TITLE, GAME_OVER} State;
  23. struct Level{
  24. int id; // 1 to 6
  25. // for the level generation
  26. Pattern* patterns;
  27. int nb_patterns;
  28. // Rotation spped. Different levels have different speed.
  29. // Just compare Hexagon and Hexagonest in the original game
  30. float player_rotation_speed;
  31. // for the camera rotation
  32. int cam_change_interval; // 5 seconds most of the time, but who knows...
  33. int cam_change_precision; // to add a bit of randomness to the intervals
  34. float cam_change_probability; // sometimes, there can be no change at all
  35. // camera speed
  36. float cam_max_speed;
  37. float cam_min_speed;
  38. 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
  39. // for the line number changes (lc prefix):
  40. int lc_min_score; // minimum score in seconds to reach before any line number change occurs
  41. float lc_probability;
  42. int lc_duration;
  43. };
  44. // the camera is defined by its center
  45. // ! and not by its upper left corner !
  46. // and an angle
  47. struct Camera{
  48. int cX;
  49. int cY;
  50. unsigned int angle;
  51. float zoom;
  52. float speed;
  53. };
  54. // a simple obstacle structure
  55. // d is the distance from the lowest face of the trapeze to the center of the screen
  56. // h is the thickness of the wall
  57. // line indicates the line that contains this obstacle
  58. // id is self explanatory
  59. // nxt is used by the linked list
  60. struct Wall{
  61. float d;
  62. unsigned int h;
  63. unsigned int id;
  64. unsigned int line;
  65. Wall *nxt;
  66. };
  67. struct Line_Transition{
  68. unsigned int counter;
  69. unsigned int counter_start;
  70. int delta_nb_lines;
  71. };
  72. struct Game_Data{
  73. //Main game data
  74. unsigned int start_time;
  75. unsigned int last_time;
  76. unsigned int current_time;
  77. float chrono_time;
  78. int player_angle;
  79. unsigned int nb_lines;
  80. Line_Transition line_transition;
  81. Wall *list;
  82. unsigned char are_colors_reversed;
  83. Level *level;
  84. Camera cam;
  85. unsigned char shift_latch_value;
  86. unsigned char alpha_latch_value;
  87. unsigned short cooldown_timer;
  88. //Start menu data
  89. unsigned int nb_entries;
  90. unsigned int current_entry; //from 1 to 6
  91. unsigned int current_entry_high_score;
  92. char **entry_difficulties; //a table of null-terminated strings
  93. float *entry_highscores;
  94. char it_s_a_highscore; // IT'S A HIGSCORE!
  95. unsigned int keypress_delay;
  96. char is_save_feature_enabled;
  97. int fileHandle;
  98. };
  99. struct Pattern{
  100. unsigned char length;
  101. unsigned char cooldown;
  102. // Should be dynamically allocated
  103. unsigned char* side;
  104. unsigned short* distance;
  105. unsigned short* wall_length;
  106. };
  107. #endif