blob: 54add558a5b7be153e396123d0f7f1743b7be055 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "square.h"
#include "node.h"
#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, 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;
}
|