Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef ENTITY_H
- #define ENTITY_H
- #include "animation/Animation.h"
- #include "camera/Camera.h"
- #define TILE_SIZE 16
- enum EntityType {
- ENTITY_TILEMAP,
- ENTITY_PLAYER,
- ENTITY_STATIC_OBJECT,
- MAX_ENTITY
- };
- static const char *entity_name[MAX_ENTITY] = {
- "Tile Map",
- "Player",
- "Static Object"
- };
- enum PlayerAnimationType {
- PLAYER_ANIM_IDLE,
- PLAYER_ANIM_RUN,
- PLAYER_ANIM_WALK,
- PLAYER_ANIM_JUMP,
- PLAYER_ANIM_FALL,
- PLAYER_ANIM_LAND,
- PLAYER_ANIM_SLEEP,
- MAX_PLAYER_ANIM
- };
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* Entity Data */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- struct Tile {
- int tx, ty;
- };
- struct TileMapData {
- Tile *tiles;
- int w, h;
- };
- struct PlayerData {
- };
- struct StaticObjectData {
- int tx, ty;
- };
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- struct Entity {
- int type;
- float x, y, w, h;
- union {
- TileMapData *tile_map_data;
- PlayerData *player_data;
- StaticObjectData *static_object_data;
- };
- };
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- Entity new_entity(int type);
- Entity new_tile_map(int w, int h);
- Entity new_player();
- Entity new_static_object(int tx, int ty, int w, int h);
- void clean_up_entity(Entity *e);
- void clean_up_tile_map(Entity *e);
- void clean_up_player(Entity *e);
- void clean_up_static_object(Entity *e);
- void request_entity_resources(Entity *e);
- void unrequest_entity_resources(Entity *e);
- bool entity_resources_ready(Entity *e);
- void update_entity(Entity *e);
- Entity *update_tile_map(Entity *e);
- Entity *update_player(Entity *e);
- Entity *update_static_object(Entity *e);
- void render_entity(Entity *e, Camera *c);
- void render_tile_map(Entity *e, Camera *c);
- void render_player(Entity *e, Camera *c);
- void render_static_object(Entity *e, Camera *c);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement