#pragma once #include "list.h" #include "gb_math.h" #include #include #include #include "asteroids_font.h" #include "xtimer.h" #ifndef STEPMULTI_X #define STEPMULTI_X (4) #endif #ifndef CHAR_OFFSET_X #define CHAR_OFFSET_X (40) #endif #ifndef STEPMULTI_Y #define STEPMULTI_Y (5) #endif #ifndef CHAR_OFFSET_Y #define CHAR_OFFSET_Y (20) #endif typedef struct{ struct {int16_t x, y; }; int16_t e[2]; } point_t; typedef enum{ PATH_MOVE = 0x0, PATH_DRAW = 0x1 } path_modus_t; typedef struct{ list_node_t list; point_t point; path_modus_t modus; } path_node_t; typedef struct{ list_node_t list; int16_t step_pos_a; int16_t step_pos_b; } step_pos_node_t; typedef struct{ list_node_t set_point_start; list_node_t start; list_node_t current; uint8_t char_count; } path_t; /** @brief Initialize path * * @param[out] path struct describing the path */ void path_init(path_t *path); /** @brief add a point to the path, * @note Always use path_add_vec if possible * * @param[in] path struct describing the path */ void path_add(path_t *path, path_node_t *point); /** @brief add a point with modus * * @param[in] path struct describing the path */ void path_add_vec(path_t *node, point_t *point, path_modus_t modus); /** @brief add a point to the path * * @param[in] path struct describing the path */ void path_generate(path_t *path); /** @brief reset path point to starting node * * @param[in] path struct describing the path */ void path_reset(path_t *path); /** @brief reverse the points in the given path * * @param[in] path struct describing the path */ void path_reverse(path_t *path); /** @brief increment the current node to the next in the path list. * Does nothing if already pointing to the last node. * * @param[in] path struct describing the path */ void path_increment(path_t *path); /** * @brief add a ascii character to the path * * @param[in] path struct describing the path * @param[in] char ascii character */ void path_add_char(path_t *path, char character); path_node_t* path_next_point(path_t *path); path_node_t* path_next(path_node_t *point); path_node_t* path_pop(path_node_t *point); point_t point_sub(point_t *a, point_t *b); point_t point_add(point_t *a, point_t *b); point_t point_interval(point_t *a, point_t*b); int16_t point_mag2(point_t *a);