summaryrefslogtreecommitdiff
path: root/src/tiled.h
blob: de469be9c5866043fb437dae39741a111e898c3b (plain)
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
#include <raylib.h>

#include "tiledmap.h"

#define SCREEN_W 1280
#define SCREEN_H 720

#define RENDER_DISTANCE 16

typedef struct Tiled {
    TiledMap tiledMap;
    float zoom;
    
    // main viewport offset
    Vector2 offset;

    // offset passed to shader for rendering
    Vector2 renderOffset;
    // offset used to calculate which chunks to render
    int chunkOffset[2];

    int atlasSize[2];
    int renderArea[2];

    Texture2D atlasTexture;

    RenderTexture2D tilemapTexture;
    RenderTexture2D targetTexture;
    Shader shader; 

    int zoomLoc;
    int offsetLoc;

    int atlasSizeLoc;
    int renderAreaLoc;

    int atlasTextureLoc;
    int tilemapTextureLoc;
} Tiled;

void updateTiledCamera(Tiled *tiled);
Vector2 translateTiledPosition(Tiled tiled, Vector2 screenPos);
Vector2 translateTiledScreenPosition(Tiled tiled, Vector2 tiledPos);
Tiled initTiled(TiledMap tiledMap);
void drawTiled(Tiled *tiled);
void unloadTiled(Tiled *tiled);
void redrawTiledMap(Tiled tiled);
void redrawTile(Tiled tiled, int x, int y);