-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld.h
39 lines (33 loc) · 1.17 KB
/
world.h
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
#pragma once
#include "math.h"
static const int SCREEN_TILE_WIDTH = 20;
static const int SCREEN_TILE_HEIGHT = 12;
static const float PIXELS_PER_UNIT = 48.0f;
struct Chunk {
uint32_t* tiles;
};
struct World {
uint32_t numChunksX;
uint32_t numChunksY;
uint32_t numChunksZ;
Chunk* chunks; // Multi demensional array
int tilesPerChunk;
int bitsForTiles;
float tileSize;
};
struct AbsoluteCoordinate {
uint32_t x; // (32-n) bits for chunk index, n for tile index
uint32_t y; // ...
uint32_t z; // all 32 bits for chunk index, theres no tile separation in z
// TODO check if this impacts anything, added on day 50 more or less
Vector2 offset; // Offset from tile center
bool operator ==(AbsoluteCoordinate other) {
return other.x == x && other.y == y && other.z == z && offset == other.offset;
}
bool operator !=(AbsoluteCoordinate other) { // TODO rewrite basing on the other one
return !(other.x == x && other.y == y && other.z == z && offset == other.offset);
}
AbsoluteCoordinate operator -(AbsoluteCoordinate other) {
return { x - other.x, y - other.y, z - other.z, offset - other.offset };
}
};