Advertisement
Cinestra

Project 3 Actor.h Part 1 (Actually finished)

May 29th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. #ifndef ACTOR_H_
  2. #define ACTOR_H_
  3.  
  4. #include "GraphObject.h"
  5.  
  6. // Students: Add code to this file, Actor.cpp, StudentWorld.h, and StudentWorld.cpp
  7.  
  8. const int PEACH = 1;
  9. const int YOSHI = 2;
  10. const int WAITING_TO_ROLL = false;
  11. const int WALKING = true;
  12. const int invalid_direction = -100;
  13.  
  14. class StudentWorld;
  15.  
  16. /*
  17. From Graph Object:
  18.  
  19. static const int left = 180;
  20. static const int right = 0;
  21. static const int up = 90;
  22. static const int down = 270;
  23.  
  24. GraphObject(int imageID, int startX, int startY, int dir = right, int depth = 0, double size = 1.0)
  25. */
  26.  
  27. class Actor : public GraphObject
  28. {
  29. public:
  30. Actor(int imageID, int startX, int startY, StudentWorld* world, int depth = 0, int dir = right, double size = 1.0)
  31. :GraphObject(imageID, startX, startY, dir, depth, size)
  32. {
  33. m_world = world;
  34. }
  35.  
  36. virtual ~Actor() {}
  37.  
  38. virtual void do_something() = 0;
  39.  
  40. StudentWorld* get_world() const {
  41. return m_world;
  42. }
  43.  
  44. private:
  45. StudentWorld* m_world;
  46. };
  47.  
  48. class Character : public Actor
  49. {
  50. public:
  51. Character(int imageID, int startX, int startY, StudentWorld* world)
  52. :Actor(imageID, startX, startY, world)
  53. {
  54. m_state = WAITING_TO_ROLL;
  55. m_ticks_to_move = 0;
  56. m_walk_direction = 0;
  57. }
  58.  
  59. virtual ~Character() {
  60.  
  61. }
  62.  
  63. int get_walk_direction() const {
  64. return m_walk_direction;
  65. }
  66.  
  67. void set_walk_direction(int walk_direction) {
  68. m_walk_direction = walk_direction;
  69. }
  70.  
  71. int get_ticks() const {
  72. return m_ticks_to_move;
  73. }
  74.  
  75. int get_state() const {
  76. return m_state;
  77. }
  78.  
  79. void set_state(bool state) {
  80. m_state = state;
  81. }
  82.  
  83. void set_ticks(int ticks) {
  84. m_ticks_to_move = ticks;
  85. }
  86.  
  87. bool can_move_in_direction(int dir) const;
  88. int get_random_direction() const;
  89. void update_sprite_direction();
  90. void do_corner_turn();
  91.  
  92. // Have not implemented ANY of the virtual void functions, must do in inhereted classes
  93.  
  94. private:
  95. int m_ticks_to_move;
  96. int m_state;
  97. int m_walk_direction;
  98. };
  99.  
  100. class Player : public Character
  101. {
  102. public:
  103. Player(int player_number, int startX, int startY, StudentWorld* world)
  104. :Character(player_number == 1 ? IID_PEACH : IID_YOSHI, startX, startY, world)
  105. {
  106. m_player_number = player_number;
  107. }
  108. virtual ~Player() {}
  109.  
  110. virtual void do_something();
  111.  
  112.  
  113. private:
  114. int m_player_number;
  115. };
  116.  
  117. class Square : public Actor
  118. {
  119. public:
  120. Square(int imageID, int startX, int startY, StudentWorld* world, int depth = 1, int dir = right, bool active = true)
  121. :Actor(imageID, startX, startY, world, 1)
  122. {
  123. m_active = active;
  124. }
  125.  
  126. virtual ~Square()
  127. {
  128.  
  129. }
  130.  
  131. virtual void do_something();
  132.  
  133. bool is_active() {
  134. return m_active;
  135. }
  136.  
  137. void set_active(bool active) {
  138. m_active = active;
  139. }
  140.  
  141. private:
  142. bool m_active;
  143. };
  144.  
  145. class Coin_Square : public Square
  146. {
  147. public:
  148. Coin_Square(int coins, int startX, int startY, StudentWorld* world)
  149. :Square(IID_BLUE_COIN_SQUARE, startX, startY, world)
  150. {
  151. m_coins = coins;
  152. }
  153.  
  154. virtual ~Coin_Square() {}
  155.  
  156. private:
  157. int m_coins;
  158. };
  159.  
  160. #endif // ACTOR_H_
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement