entities.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _entities_h
  2. #define _entities_h
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "types.h"
  6. // Shortcuts
  7. //#define create_player(x, y) {create_coords((double) x + (double)0.5, (double) y + (double)0.5), create_coords(1, 0), create_coords(0, -0.66), 0, 100}
  8. #define create_enemy(x, y) create_entity(E_ENEMY, x, y, S_STAND, 50)
  9. #define create_medikit(x, y) create_entity(E_MEDIKIT, x, y, S_STAND, 0)
  10. #define create_key(x, y) create_entity(E_KEY, x, y, S_STAND, 0)
  11. #define create_fireball(x, y, dir) create_entity(E_FIREBALL, x, y, S_STAND, dir)
  12. #define create_door(x, y) create_entity(E_DOOR, x, y, S_STAND, 0)
  13. // entity statuses
  14. #define S_STAND 0
  15. #define S_ALERT 1
  16. #define S_FIRING 2
  17. #define S_MELEE 3
  18. #define S_HIT 4
  19. #define S_DEAD 5
  20. #define S_HIDDEN 6
  21. #define S_OPEN 7
  22. #define S_CLOSE 8
  23. typedef struct Player {
  24. Coords pos;
  25. Coords dir;
  26. Coords plane;
  27. double velocity;
  28. uint8_t health;
  29. uint8_t keys;
  30. } Player;
  31. typedef struct Entity {
  32. UID uid;
  33. Coords pos;
  34. uint8_t state;
  35. uint8_t health; // angle for fireballs
  36. uint8_t distance;
  37. uint8_t timer;
  38. } Entity;
  39. typedef struct StaticEntity {
  40. UID uid;
  41. uint8_t x;
  42. uint8_t y;
  43. bool active;
  44. } StaticEntity;
  45. Entity
  46. create_entity(uint8_t type, uint8_t x, uint8_t y, uint8_t initialState, uint8_t initialHealth);
  47. StaticEntity create_static_entity(UID uid, uint8_t x, uint8_t y, bool active);
  48. Player create_player(double x, double y);
  49. #endif