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 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;
- 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 = WAITING_TO_ROLL;
- 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();
- // 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;
- };
- 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;
- }
- virtual ~Player() {}
- virtual void do_something();
- private:
- int m_player_number;
- };
- 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();
- 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() {}
- private:
- int m_coins;
- };
- #endif // ACTOR_H_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement