Nodes now calculate their coordinates. But the code now only wirks with triangles.

This commit is contained in:
2021-01-08 20:33:58 +01:00
parent d966d2ef8e
commit 2715d5aa6a
5 changed files with 30 additions and 35 deletions

View File

@ -3,15 +3,28 @@
#include "config.h"
#include "edge.h"
#include "corner.h"
#include "prototypes.h"
// Delta-X data. Per direction of a triangle is a triple with Delta-X values for each direction.
static const int8_t dx[][3] = {{0, 1, -1}, {1, 0, -1}, {1, -1, 0}, {0, -1, 1}, {-1, 0, 1}, {-1, 1, 0}};
static const int8_t dy[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, -1}, {1, 0, 0}, {0, -1, 0}, {0, 0, 1}};
typedef struct {
int8_t x;
int8_t y;
} Coords;
class Node {
private:
uint16_t _number;
Coords coords_at_direction(uint8_t edge);
public:
Coords coords;
uint8_t direction;
Node* neighbours[CORNERS_PER_PART];
Edge* edges[CORNERS_PER_PART];
Corner* _corners[CORNERS_PER_PART];
Node(uint16_t number);
Node(uint16_t number, Coords c, uint8_t direction);
Node* create_neighbour(uint8_t edge);
void blend_to(CRGB color, uint16_t effect_id=0, uint8_t effect_speed=0);

View File

@ -7,6 +7,7 @@
#include "edge.h"
#include "corner.h"
class Node;
extern std::vector<Node*> nodes;
extern std::list<Edge*> edges;