Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

118 řádky
2.4KB

  1. #pragma once
  2. #include "list.h"
  3. #include "gb_math.h"
  4. #include <stdio.h>
  5. #include <stdint.h>
  6. #include <stdlib.h>
  7. #include "asteroids_font.h"
  8. #include "xtimer.h"
  9. #ifndef STEPMULTI_X
  10. #define STEPMULTI_X (4)
  11. #endif
  12. #ifndef CHAR_OFFSET_X
  13. #define CHAR_OFFSET_X (40)
  14. #endif
  15. #ifndef STEPMULTI_Y
  16. #define STEPMULTI_Y (5)
  17. #endif
  18. #ifndef CHAR_OFFSET_Y
  19. #define CHAR_OFFSET_Y (20)
  20. #endif
  21. typedef struct{
  22. struct {int16_t x, y; };
  23. int16_t e[2];
  24. } point_t;
  25. typedef enum{
  26. PATH_MOVE = 0x0,
  27. PATH_DRAW = 0x1
  28. } path_modus_t;
  29. typedef struct{
  30. list_node_t list;
  31. point_t point;
  32. path_modus_t modus;
  33. } path_node_t;
  34. typedef struct{
  35. list_node_t list;
  36. int16_t step_pos_a;
  37. int16_t step_pos_b;
  38. } step_pos_node_t;
  39. typedef struct{
  40. list_node_t set_point_start;
  41. list_node_t start;
  42. list_node_t current;
  43. uint8_t char_count;
  44. } path_t;
  45. /** @brief Initialize path
  46. *
  47. * @param[out] path struct describing the path
  48. */
  49. void path_init(path_t *path);
  50. /** @brief add a point to the path,
  51. * @note Always use path_add_vec if possible
  52. *
  53. * @param[in] path struct describing the path
  54. */
  55. void path_add(path_t *path, path_node_t *point);
  56. /** @brief add a point with modus
  57. *
  58. * @param[in] path struct describing the path
  59. */
  60. void path_add_vec(path_t *node, point_t *point, path_modus_t modus);
  61. /** @brief add a point to the path
  62. *
  63. * @param[in] path struct describing the path
  64. */
  65. void path_generate(path_t *path);
  66. /** @brief reset path point to starting node
  67. *
  68. * @param[in] path struct describing the path
  69. */
  70. void path_reset(path_t *path);
  71. /** @brief reverse the points in the given path
  72. *
  73. * @param[in] path struct describing the path
  74. */
  75. void path_reverse(path_t *path);
  76. /** @brief increment the current node to the next in the path list.
  77. * Does nothing if already pointing to the last node.
  78. *
  79. * @param[in] path struct describing the path
  80. */
  81. void path_increment(path_t *path);
  82. /**
  83. * @brief add a ascii character to the path
  84. *
  85. * @param[in] path struct describing the path
  86. * @param[in] char ascii character
  87. */
  88. void path_add_char(path_t *path, char character);
  89. path_node_t* path_next_point(path_t *path);
  90. path_node_t* path_next(path_node_t *point);
  91. path_node_t* path_pop(path_node_t *point);
  92. point_t point_sub(point_t *a, point_t *b);
  93. point_t point_add(point_t *a, point_t *b);
  94. point_t point_interval(point_t *a, point_t*b);
  95. int16_t point_mag2(point_t *a);