summary refs log tree commit diff
path: root/src/tilemap.h
blob: ae42c9cccdba10c67c59d51486b012f04b51c809 (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
#pragma once
#include "collision.h"

extern struct tilemap {
	void *tileset;
	void *wang_tileset;
	struct {
		unsigned char r, g, b, a;
	} backdrop;
	unsigned width;
	unsigned height;
	unsigned layers;
	unsigned middleground;
	struct parallax {
		float x, y;
	} *parallax;
	collision_T *collision;
	void **tilemaps;
	size_t input_bytes;
} *tilemap, *next_tilemap;

// tilemap collision functions
collision_T tilemap_tile_raw(struct tilemap *tilemap, int x, int y);
collision_T tilemap_tile(struct tilemap *tilemap, int x, int y);

collision_T tilemap_area_raw(struct tilemap *tilemap, int x1, int y1, int x2, int y2);
collision_T tilemap_area(struct tilemap *tilemap, int x1, int y1, int x2, int y2);

// render the fore/back ground of the tilemap to `renderer`
void tilemap_background(struct tilemap *tilemap, int x, int y, int w, int h);
void tilemap_foreground(struct tilemap *tilemap, int x, int y, int w, int h);

void tilemap_free(struct tilemap *tilemap);
struct tilemap *tilemap_load(void *data, size_t size);