diff options
author | Schark <jordan@schark.online> | 2024-03-18 01:44:32 -0700 |
---|---|---|
committer | Schark <jordan@schark.online> | 2024-03-18 01:44:32 -0700 |
commit | 8e2508626776d1300b351f2326773b5bb0cb528f (patch) | |
tree | ee7daf330a91c8770ed860564c2c2d77fb138fb4 /height-map-display/src/map/square.c | |
parent | 69de9b320ad3c45e0a19845c88ae8323cfb59bf1 (diff) | |
download | gamedev-8e2508626776d1300b351f2326773b5bb0cb528f.tar.gz gamedev-8e2508626776d1300b351f2326773b5bb0cb528f.zip |
Adding selected square functionality and aesthetics
Diffstat (limited to '')
-rw-r--r-- | height-map-display/src/map/square.c | 17 |
1 files changed, 16 insertions, 1 deletions
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 <stdio.h> #include <stdlib.h> #include <malloc.h> +#include <stdbool.h> -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; +} |