game.h 770 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef _GAME_H_
  2. #define _GAME_H_
  3. typedef struct {
  4. int x;
  5. int y;
  6. } POINT;
  7. typedef struct {
  8. char direction;
  9. POINT position;
  10. POINT old_position;
  11. int value;
  12. char color;
  13. int move_tick;
  14. } BALL;
  15. typedef struct {
  16. int head_dir_x;
  17. int head_dir_y;
  18. int next_head_dir_x;
  19. int next_head_dir_y;
  20. POINT* old_tail;
  21. POINT** body;
  22. int head_ptr;
  23. int length;
  24. } PLAYER;
  25. typedef struct {
  26. int points;
  27. int status;
  28. } GAME_STATE;
  29. typedef struct {
  30. int width;
  31. int height;
  32. BALL** balls;
  33. int ball_count;
  34. int max_allocated_balls;
  35. WINDOW* win;
  36. PLAYER* player;
  37. GAME_STATE* state;
  38. } FIELD;
  39. extern GAME_STATE* state;
  40. void set_lost(GAME_STATE* state);
  41. void set_won(GAME_STATE* state);
  42. void eat_ball(FIELD* field, int pos);
  43. void play_game(GAME_STATE* state);
  44. #endif