game.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "engine/engine.h"
  3. #include <game/world.h>
  4. #include <game/level.h>
  5. #include <game/enemy.h>
  6. #include "flip_world.h"
  7. #include "flip_storage/storage.h"
  8. #define PLAYER_COLLISION_VERTICAL 5
  9. #define PLAYER_COLLISION_HORIZONTAL 5
  10. typedef enum
  11. {
  12. PLAYER_IDLE,
  13. PLAYER_MOVING,
  14. PLAYER_ATTACKING,
  15. PLAYER_DEAD,
  16. } PlayerState;
  17. typedef enum
  18. {
  19. PLAYER_UP,
  20. PLAYER_DOWN,
  21. PLAYER_LEFT,
  22. PLAYER_RIGHT
  23. } PlayerDirection;
  24. typedef struct
  25. {
  26. PlayerDirection direction; // direction the player is facing
  27. PlayerState state; // current state of the player
  28. Sprite *sprite_right; // player sprite looking right
  29. Sprite *sprite_left; // player sprite looking left
  30. int8_t dx; // x direction
  31. int8_t dy; // y direction
  32. uint32_t xp; // experience points
  33. uint32_t level; // player level
  34. uint32_t health; // player health
  35. uint32_t strength; // player strength
  36. } PlayerContext;
  37. typedef struct
  38. {
  39. float fps;
  40. PlayerContext *player;
  41. } GameContext;
  42. extern const EntityDescription player_desc;
  43. void player_spawn(Level *level, GameManager *manager);
  44. // Get game context: GameContext* game_context = game_manager_game_context_get(manager);