2024-07-08 00:44:20 +00:00
|
|
|
#ifndef WORLD_H
|
|
|
|
#define WORLD_H
|
|
|
|
|
2024-09-23 17:43:16 +00:00
|
|
|
#include "twn_game_api.h"
|
|
|
|
|
2024-07-08 00:44:20 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
2024-09-23 17:43:16 +00:00
|
|
|
typedef enum TileType {
|
2024-07-08 00:44:20 +00:00
|
|
|
TILE_TYPE_VOID,
|
|
|
|
TILE_TYPE_SOLID,
|
2024-09-23 17:43:16 +00:00
|
|
|
} TileType;
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
|
2024-09-23 17:43:16 +00:00
|
|
|
typedef struct Tile {
|
|
|
|
Recti rect;
|
|
|
|
TileType type;
|
|
|
|
} Tile;
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
|
2024-09-23 17:43:16 +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;
|
2024-09-23 17:43:16 +00:00
|
|
|
} World;
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
|
2024-09-23 17:43:16 +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
|