Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef ACTOR_H_
- #define ACTOR_H_
- #include "GraphObject.h"
- // Students: Add code to this file, Actor.cpp, StudentWorld.h, and StudentWorld.cpp
- const int PEACH = 1;
- const int YOSHI = 2;
- const int WAITING_TO_ROLL = false;
- const int PAUSED = false;
- const int WALKING = true;
- const int invalid_direction = -100;
- class StudentWorld;
- /*
- From Graph Object:
- static const int left = 180;
- static const int right = 0;
- static const int up = 90;
- static const int down = 270;
- GraphObject(int imageID, int startX, int startY, int dir = right, int depth = 0, double size = 1.0)
- */
- class Actor : public GraphObject
- {
- public:
- Actor(int imageID, int startX, int startY, StudentWorld* world, int depth = 0, int dir = right, double size = 1.0)
- :GraphObject(imageID, startX, startY, dir, depth, size)
- {
- m_world = world;
- }
- virtual ~Actor() {}
- virtual void do_something() = 0; // Does something during the tick
- virtual bool is_impactable() = 0;
- virtual void do_impacted_behavior() = 0;
- virtual bool is_square() = 0;
- virtual bool is_dynamically_added() = 0;
- StudentWorld* get_world() const {
- return m_world;
- }
- private:
- StudentWorld* m_world;
- };
- class Character : public Actor
- {
- public:
- Character(int imageID, int startX, int startY, StudentWorld* world)
- :Actor(imageID, startX, startY, world)
- {
- m_state = 0; // 0 stands for either waiting to roll or paused
- m_ticks_to_move = 0;
- m_walk_direction = 0;
- }
- virtual ~Character() {}
- int get_walk_direction() const {
- return m_walk_direction;
- }
- void set_walk_direction(int walk_direction) {
- m_walk_direction = walk_direction;
- }
- int get_ticks() const {
- return m_ticks_to_move;
- }
- int get_state() const {
- return m_state;
- }
- void set_state(bool state) {
- m_state = state;
- }
- void set_ticks(int ticks) {
- m_ticks_to_move = ticks;
- }
- bool can_move_in_direction(int dir) const;
- int get_random_direction() const;
- void update_sprite_direction();
- void do_corner_turn();
- bool is_at_fork();
- // Have not implemented ANY of the virtual void functions, must do in inhereted classes
- private:
- int m_ticks_to_move;
- int m_state;
- int m_walk_direction;
- };
- // Must implement the following:
- /* virtual void do_something() = 0; // Does something during the tick
- virtual void do_impaceted_behavior() = 0; // If it's impactable by a vortex, it does it's impacted behavior
- virtual bool is_square() = 0; // Determines if it's a static object or not
- virtual bool is_impactable() = 0; // Can this be hit by a vortex
- virtual bool is_dynamically_added() = 0; // Was this just added to the board
- *
- */
- class Player : public Character
- {
- public:
- Player(int player_number, int startX, int startY, StudentWorld* world)
- :Character(player_number == 1 ? IID_PEACH : IID_YOSHI, startX, startY, world)
- {
- m_player_number = player_number;
- m_coins = 0;
- m_stars = 0;
- }
- virtual ~Player() {}
- virtual void do_something();
- virtual bool is_impactable() {
- return false;
- }
- virtual void do_impacted_behavior() {
- }
- virtual bool is_square() {
- return false;
- }
- virtual bool is_dynamically_added() {
- return false;
- }
- void set_coins(int coins) { m_coins = coins; }
- int get_coins() const { return m_coins; }
- void set_stars(int stars) { m_stars = stars; }
- int get_stars() const { return m_stars; }
- private:
- int m_player_number;
- int m_coins;
- int m_stars;
- };
- class Baddie : public Character
- {
- public:
- Baddie(int max_possible_squares_to_move, int imageID, int startX, int startY, StudentWorld* world)
- :Character(imageID, startX, startY, world)
- {
- m_max_possible_squares_to_move = max_possible_squares_to_move;
- m_pause_counter = 180;
- m_players_on_square = new std::set<Player*>;
- }
- virtual ~Baddie();
- virtual void do_something();
- virtual void do_impacted_behavior();
- virtual bool is_impactable() { return true; }
- virtual bool is_dynamically_added(){ return false; }
- virtual bool is_square() { return false; }
- private:
- virtual void do_baddie_behavior(Player* player) = 0;
- int m_max_possible_squares_to_move;
- int m_pause_counter;
- // Player* is a pointer to a player class
- // Set<Player*> is a set of pointers to the player class
- // Set<Player*>* is a pointer to a set of pointers to the player class
- std::set<Player*>* m_players_on_square;
- void update_players_on_square(std::set<Player*>& updated);
- virtual void do_special_pause_behavior() = 0; // Only for Bowser
- };
- class Boo : public Baddie
- {
- public:
- Boo(int startX, int startY, StudentWorld* world)
- :Baddie(3, IID_BOO, startX, startY, world)
- {
- }
- virtual ~Boo() {};
- private:
- virtual void do_baddie_behavior(Player* player);
- virtual void do_special_pause_behavior() { } // Does nothing
- };
- class Bowser : public Baddie
- {
- public:
- Bowser(int startX, int startY, StudentWorld* world)
- :Baddie(10, IID_BOWSER, startX, startY, world)
- {
- }
- virtual ~Bowser() {}
- private:
- virtual void do_baddie_behavior(Player* player);
- virtual void do_special_pause_behavior();
- };
- class Square : public Actor
- {
- public:
- Square(int imageID, int startX, int startY, StudentWorld* world, int depth = 1, int dir = right, bool active = true)
- :Actor(imageID, startX, startY, world, 1)
- {
- m_active = active;
- }
- virtual ~Square() {}
- virtual void do_something();
- virtual bool is_impactable() {
- return false;
- }
- virtual void do_impacted_behavior() {
- }
- virtual bool is_square() {
- return true;
- }
- virtual bool is_dynamically_added() {
- return true;
- }
- bool is_active() {
- return m_active;
- }
- void set_active(bool active) {
- m_active = active;
- }
- private:
- bool m_active;
- };
- class Coin_Square : public Square
- {
- public:
- Coin_Square(int coins, int startX, int startY, StudentWorld* world)
- :Square(IID_BLUE_COIN_SQUARE, startX, startY, world)
- {
- m_coins = coins;
- }
- virtual ~Coin_Square() {}
- virtual bool is_dynamically_added() {
- return false;
- }
- private:
- int m_coins;
- };
- #endif // ACTOR_H_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement