Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.00 KB | None | 0 0
  1. #ifndef ENTITY_H
  2. #define ENTITY_H
  3.  
  4. #include "animation/Animation.h"
  5. #include "camera/Camera.h"
  6.  
  7. #define TILE_SIZE 16
  8.  
  9. enum EntityType {
  10.     ENTITY_TILEMAP,
  11.     ENTITY_PLAYER,
  12.     ENTITY_STATIC_OBJECT,
  13.     MAX_ENTITY
  14. };
  15.  
  16. static const char *entity_name[MAX_ENTITY] = {
  17.     "Tile Map",
  18.     "Player",
  19.     "Static Object"
  20. };
  21.  
  22. enum PlayerAnimationType {
  23.     PLAYER_ANIM_IDLE,
  24.     PLAYER_ANIM_RUN,
  25.     PLAYER_ANIM_WALK,
  26.     PLAYER_ANIM_JUMP,
  27.     PLAYER_ANIM_FALL,
  28.     PLAYER_ANIM_LAND,
  29.     PLAYER_ANIM_SLEEP,
  30.     MAX_PLAYER_ANIM
  31. };
  32.  
  33. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  34. /*                          Entity Data                          */
  35. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  36.  
  37. struct Tile {
  38.     int tx, ty;
  39. };
  40.  
  41. struct TileMapData {
  42.     Tile *tiles;
  43.     int w, h;
  44. };
  45.  
  46. struct PlayerData {
  47.  
  48. };
  49.  
  50. struct StaticObjectData {
  51.     int tx, ty;
  52. };
  53.  
  54. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  55.  
  56. struct Entity {
  57.     int type;
  58.     float x, y, w, h;
  59.  
  60.     union {
  61.         TileMapData *tile_map_data;
  62.         PlayerData *player_data;
  63.         StaticObjectData *static_object_data;
  64.     };
  65. };
  66.  
  67. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  68.  
  69. Entity new_entity(int type);
  70. Entity new_tile_map(int w, int h);
  71. Entity new_player();
  72. Entity new_static_object(int tx, int ty, int w, int h);
  73.  
  74. void clean_up_entity(Entity *e);
  75. void clean_up_tile_map(Entity *e);
  76. void clean_up_player(Entity *e);
  77. void clean_up_static_object(Entity *e);
  78.  
  79. void request_entity_resources(Entity *e);
  80. void unrequest_entity_resources(Entity *e);
  81. bool entity_resources_ready(Entity *e);
  82.  
  83. void update_entity(Entity *e);
  84. Entity *update_tile_map(Entity *e);
  85. Entity *update_player(Entity *e);
  86. Entity *update_static_object(Entity *e);
  87.  
  88. void render_entity(Entity *e, Camera *c);
  89. void render_tile_map(Entity *e, Camera *c);
  90. void render_player(Entity *e, Camera *c);
  91. void render_static_object(Entity *e, Camera *c);
  92.  
  93. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement