-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChunk.h
58 lines (50 loc) · 1.53 KB
/
Chunk.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef CHUNK_H
#define CHUNK_H
#include "Entity.h"
#include "Block.h"
#include "Tilemap.h"
#include "Player.h"
#include <string.h>
#include "Coordinate.h"
typedef struct Chunk_S
{
struct Entitieslist_S *m_entities_list;
Block_s ***m_blocks;
Coordinate_s world_position;
} Chunk_s;
// width and height for each chunks
#define CHUNK_SIZE 10
/**
* @brief Create a Chunk From Tilemap object
*
* @param tilemap
* @param top_coord The (x,y) coordinates of the top left corner of the chunk
* @return struct Chunk_s* The loaded chunk from the tilemap
*/
Chunk_s *CreateChunkFromTilemap(struct Tilemap_S *tilemap, struct Coordinate_S top_coord);
/**
* @brief Adding an entity to a chunk
*
* @param chunk
* @param entity
*/
void AddEntityToChunk(Chunk_s *chunk, struct Entity_S *entity);
/**
* @brief Return a (x, y) coordinate in world referential to a (x, y) coordinate with chunk referential
*
* @param tilemap_coord
* @return struct Coordinate_s
*/
Coordinate_s TilemapToChunkCoordinates(Coordinate_s tilemap_coord);
/**
* @brief Load all the 10 chunks around the player
*
* @param player
*/
void LoadChunkAroundPlayer(struct Player_S *player, float seed, bool first, int chunkCount_x, int chunkCount_y);
void writeFileToChunk(Chunk_s *chunk, const char *filename, long cursor);
void writeChunkToFile(Chunk_s *chunk, const char *filename);
void writeChunkToFileAt(Chunk_s *chunk, const char *filename, long cursor);
long whereisChunkInFile(Coordinate_s chunk_coord, const char *filename);
void freeChunk(Chunk_s *chunk);
#endif