#include "square.h" #include "node.h" #include #include #include #include Square* init_square(Node *tl, Node *tr, Node *bl, Node *br, Terrain_Type terrain, bool selected) { Square* square; square->node_tl = tl; square->node_tr = tr; square->node_bl = bl; square->node_br = br; square->terrain = terrain; square->selected = selected; return square; } void change_square_height(Square* square, float diff) { square->node_tl->elevation = square->node_tl->elevation + diff; square->node_tr->elevation = square->node_tr->elevation + diff; square->node_bl->elevation = square->node_bl->elevation + diff; square->node_br->elevation = square->node_br->elevation + diff; } void change_square_terrain(Square* square, Terrain_Type terrain) { square->terrain = terrain; } // TODO: Probably a better way of storing selected square tbh Square* find_selected_square(Square*** squares, int x, int y) { for (int i = 0; i < x - 1; i++) { for (int i = 0; i < x - 1; i++) { if (squares[x][y]->selected) { return squares[x][y]; } } } return NULL; }