townengine/apps/demos/platformer/world.h

45 lines
890 B
C

#ifndef WORLD_H
#define WORLD_H
#include "twn_game_api.h"
#include <stdint.h>
#include <stdbool.h>
typedef enum TileType {
TILE_TYPE_VOID,
TILE_TYPE_SOLID,
} TileType;
typedef struct Tile {
Recti rect;
TileType type;
} Tile;
typedef struct World {
TileType **tilemap;
Tile *tiles;
int tile_size;
unsigned int tilemap_width;
unsigned int tilemap_height;
size_t tile_nonvoid_count;
float gravity;
} World;
World *world_create(void);
void world_destroy(World *world);
void world_drawdef(World *world);
bool world_find_intersect_frect(World *world, Rect rect, Rect *intersection);
bool world_find_intersect_rect(World *world, Recti rect, Recti *intersection);
bool world_is_tile_at(World *world, float x, float y);
void world_place_tile(World *world, float x, float y);
void world_remove_tile(World *world, float x, float y);
#endif