struct.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef STRUCT_H
  2. #define STRUCT_H
  3. //constants
  4. #define PI 3.14159265
  5. #define SIN_60 0.866025404
  6. #define COS_60 0.5
  7. #define true 1
  8. #define false 0
  9. #define bool unsigned char
  10. //macros
  11. #define abs(x) x>0 ? x : -x
  12. typedef enum {PATTERN} Pattern_Enum;
  13. typedef struct Camera Camera;
  14. typedef struct Wall Wall;
  15. typedef struct Line Line;
  16. typedef struct Level Level;
  17. struct Level{
  18. //for the level generation
  19. Pattern_Enum available_patterns[32][32];
  20. int nb_patterns;
  21. //for the camera rotation
  22. int change_interval; //5 seconds most of the time, but who knows...
  23. int change_precision; //to add a bit of randomness to the intervals
  24. float change_probability; //sometimes, there can be no change at all
  25. float max_speed;
  26. float min_speed;
  27. 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
  28. };
  29. //the camera is defined by its center
  30. // ! and not by its upper left corner !
  31. //and an angle
  32. struct Camera{
  33. int cX;
  34. int cY;
  35. int angle;
  36. float speed;
  37. };
  38. //a simple obstacle structure
  39. //d is the distance from the lowest face of the trapeze to the center of the screen
  40. //h is the thickness of the wall
  41. //line indicates the line that contains this obstacle
  42. //id is self explanatory
  43. //nxt is used by the linked list
  44. struct Wall{
  45. float d;
  46. int h;
  47. int id;
  48. int line;
  49. Wall *nxt;
  50. };
  51. #endif