2 * Copyright 2018-2020 Iwo 'Outfrost' Bujkiewicz
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 #include "engine/asset.h"
18 BLOCKTYPE_OBSTACLE_X = 1 << 0,
19 BLOCKTYPE_OBSTACLE_Z = 1 << 1
28 OBSTACLE_XP_ZP = 1 << 4,
29 OBSTACLE_XP_ZN = 1 << 5,
30 OBSTACLE_XN_ZP = 1 << 6,
31 OBSTACLE_XN_ZN = 1 << 7
34 typedef enum BlockType BlockType;
35 typedef enum Obstacle Obstacle;
36 typedef struct Block Block;
37 typedef struct BlockGrid BlockGrid;
38 typedef struct GridLocation GridLocation;
56 static const float BLOCKGRID_CELL_SIZE = 2.5f;
58 extern BlockGrid levelGrid;
62 GridLocation gridLocationFromPosition(Vector pos);
63 Obstacle getObstacles(GridLocation loc);
65 static inline Block* getBlockFromGrid(BlockGrid grid, size_t x, size_t z) {
66 return grid.blocks[(z * grid.width) + x];
69 static inline void setBlockInGrid(BlockGrid grid, size_t x, size_t z, Block* block) {
70 grid.blocks[(z * grid.width) + x] = block;
73 static inline float cellBoundaryCoord(size_t cellIndex) {
74 return cellIndex * BLOCKGRID_CELL_SIZE;