townengine/apps/testgame/world.h

45 lines
890 B
C
Raw Normal View History

2024-07-08 00:44:20 +00:00
#ifndef WORLD_H
#define WORLD_H
#include "twn_game_api.h"
2024-07-08 00:44:20 +00:00
#include <stdint.h>
#include <stdbool.h>
typedef enum TileType {
2024-07-08 00:44:20 +00:00
TILE_TYPE_VOID,
TILE_TYPE_SOLID,
} TileType;
2024-07-08 00:44:20 +00:00
typedef struct Tile {
Recti rect;
TileType type;
} Tile;
2024-07-08 00:44:20 +00:00
typedef struct World {
TileType **tilemap;
Tile *tiles;
2024-07-08 00:44:20 +00:00
int tile_size;
unsigned int tilemap_width;
unsigned int tilemap_height;
size_t tile_nonvoid_count;
float gravity;
} World;
2024-07-08 00:44:20 +00:00
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);
2024-07-08 00:44:20 +00:00
#endif