summaryrefslogtreecommitdiff
path: root/height-map-display/src/map/square.c
blob: f963fa39f24da64e9546bc0e9f367cb6372b0551 (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
#include "square.h"
#include "node.h"

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

Square* init_square(Node *tl, Node *tr, Node *bl, Node *br, Terrain_Type terrain) {
    Square* square;
    square->node_tl = tl;
    square->node_tr = tr;
    square->node_bl = bl;
    square->node_br = br;
    square->terrain = terrain;
    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; 
}