spaceship.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @file spaceship.h
  3. * @brief spawn, move, update and init struct_player
  4. */
  5. /**
  6. * @def SPACESHIP_H
  7. */
  8. #include <allegro5/allegro5.h>
  9. #include <stdbool.h>
  10. #ifndef SPACESHIP_H
  11. #define SPACESHIP_H
  12. #define SHIP_MAX 1
  13. #define SHIP_SCALE 1.0f
  14. #define SHIP_COLOR al_map_rgb(0,200,0)
  15. /**
  16. * @struct struct_player
  17. * structure to define general enemy with basic parameters.
  18. * @param sx - x coordinate on the plane
  19. * @param sy - y coordinate on the plane
  20. * @param heading - velocity vector of the ship(in radians)
  21. * @param twist - how the "sprite" is rotated
  22. * @param gone - is it dead
  23. * @param accel - is it accelerating
  24. * @param color - ALLEGRO_COLOR structure
  25. * */
  26. typedef struct struct_player {
  27. float sx;
  28. float sy;
  29. float heading;
  30. float twist;
  31. float speed;
  32. bool gone;
  33. bool accel;
  34. ALLEGRO_COLOR color;
  35. } Spaceship;
  36. /**
  37. * @fn void ship_update(Spaceship *s)
  38. * updates ship status.
  39. * @param s - pointer to the spaceship being updated.
  40. */
  41. void ship_update(Spaceship *s);
  42. /**
  43. * @fn void ship_check_pos(Spaceship *s)
  44. * checks for the spaceship position. If it's out of bounds, return it to the screen.
  45. * @param s - spaceship being updated. Should exist only one.
  46. */
  47. void ship_check_pos(Spaceship *s);
  48. /**
  49. * @fn void ship_speed(Spaceship *s, void (*change)(float*))
  50. * changes ship speed with one of the movement functions
  51. * @param s - pointer to the ship
  52. * @param change - pointer to the movement function
  53. */
  54. void ship_speed(Spaceship *s, void (*change)(float*));
  55. /**
  56. * @fn void ship_init(Spaceship *s)
  57. * initializes the spaceship. Does not allocates memory.
  58. * @param s - the only spaceship. Should not be NULL.
  59. */
  60. void ship_init(Spaceship *s);
  61. /**
  62. * @fn void ship_move(Spaceship *s, void (*direction)(float*, float*, float, float))
  63. * moves the ship with one of the movement functions.
  64. * @param s - pointer to the ship to move
  65. * @param direction - in what direction to move the ship. The basic movement functions.
  66. */
  67. void ship_move(Spaceship *s, void (*direction)(float*, float*, float, float));
  68. /**
  69. * @fn void ship_rotate(Spaceship *s, void (*direction)(float*))
  70. * rotate the ship with one of the movement function.
  71. * @param s - pointer to the ship to rotate
  72. * @param direction - rotate the ship CW and CCW. The basic movement functions.
  73. */
  74. void ship_rotate(Spaceship *s, void (*direction)(float*));
  75. #endif /* include SPACESHIP_H */