From 8e2508626776d1300b351f2326773b5bb0cb528f Mon Sep 17 00:00:00 2001 From: Schark Date: Mon, 18 Mar 2024 01:44:32 -0700 Subject: Adding selected square functionality and aesthetics --- height-map-display/src/map/square.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'height-map-display/src/map/square.c') diff --git a/height-map-display/src/map/square.c b/height-map-display/src/map/square.c index f963fa3..54add55 100644 --- a/height-map-display/src/map/square.c +++ b/height-map-display/src/map/square.c @@ -4,14 +4,16 @@ #include #include #include +#include -Square* init_square(Node *tl, Node *tr, Node *bl, Node *br, Terrain_Type terrain) { +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; } @@ -25,3 +27,16 @@ void change_square_height(Square* square, float 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; +} -- cgit v1.2.3-18-g5258