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

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

Node* create_node(int x, int y, float elevation) {
    Node* node = (Node*)malloc(sizeof(Node));
    if (node != NULL) {
        node->x = x;
        node->y = y;
        node->elevation = elevation;
    }
    return node;
}

void change_node_height(Node* node, float diff) {
    if (node != NULL) { node->elevation = node->elevation + diff; }
}

int* get_coords(Node* node) {
    int *coordinate = malloc(2 * sizeof(int));
    if (coordinate != NULL) {
        coordinate[0] = node->x;
        coordinate[1] = node->y;
    }
    return coordinate;
}