blasteroids.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @file blasteroids.h
  3. * @brief engine of the game. All logic and settings are here
  4. */
  5. /**
  6. * @def BLASTEROIDS_H
  7. */
  8. /* Project */
  9. #include <asteroid.h>
  10. #include <blast.h>
  11. #include <spaceship.h>
  12. #ifndef BLASTEROIDS_H
  13. #define BLASTEROIDS_H
  14. #define WIDTH 800
  15. #define HEIGHT 600
  16. #define FPS 60.0f
  17. #define KEYS_MAX 5
  18. #define ASTR_COLOR al_map_rgb(255,255,255)
  19. #define BG_COLOR al_map_rgb(0,0,30)
  20. enum enum_buttons {
  21. FW, BW, CW, CC, EX
  22. };
  23. /**
  24. * @fn void al_clear_keyboard_state(ALLEGRO_DISPLAY *display) - added so the funciton was defined.
  25. * for some reason function exists, but is not defined in allegro library.
  26. */
  27. void al_clear_keyboard_state(ALLEGRO_DISPLAY *display);
  28. /**
  29. * @fn void blasteroids_check_collision(Asteroid *a, Spaceship *s) - checks for collision between asteroid and spaceship.
  30. * @param a - asteroid to check collision with s
  31. * @param s - spaceship of the player
  32. */
  33. void blasteroids_check_collision(Asteroid *a, Spaceship *s);
  34. /**
  35. * @fn void blasteroids_init_control(void) - initializes all control using allegro library.
  36. */
  37. void blasteroids_init_control(void);
  38. /**
  39. * @fn void blasteroids_init_display(void) - initalizes the game window with allegro.
  40. * The size of the window is hardcoded into the WIDTH and HEIGHT constants.
  41. */
  42. void blasteroids_init_display(void);
  43. /**
  44. * @fn void blasteroids_init_timer(void) - initializes the allegro timer.
  45. */
  46. void blasteroids_init_timer(void);
  47. /**
  48. * @fn void blasteroids_init_events(void) - initializes the allegro events and registers all event sources(timer included).
  49. */
  50. void blasteroids_init_events(void);
  51. /**
  52. * @fn void blasteroids_loop(void) - main loop of the game, it runs until you close the display or press ESC.
  53. */
  54. void blasteroids_loop(void);
  55. /**
  56. * void blasteroids_exit(Spaceship *s, Asteroid **a, bool *keys,ALLEGRO_EVENT *event, ALLEGRO_TIMER *timer, ALLEGRO_EVENT_QUEUE *queue)
  57. * when blasteroids_loop ends it calls for blasteroids_exit to free allocated memory.
  58. * @param s - pointer to the spaceship
  59. * @param a - pointer to the array of Asteroid
  60. * @param keys - pointer to array of pressed keys
  61. * @param event - pointer to created ALLEGRO_EVENT event
  62. * @param timer - pointer to created ALLEGRO_TIMER timer
  63. * @param queue - pointer to created ALLEGRO_EVENT_QUEUE
  64. */
  65. void blasteroids_exit(Spaceship *s, Asteroid **a, bool *keys,
  66. ALLEGRO_EVENT *event, ALLEGRO_TIMER *timer, ALLEGRO_EVENT_QUEUE *queue);
  67. #endif