-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.h
More file actions
41 lines (25 loc) · 1.55 KB
/
Copy pathGameObject.h
File metadata and controls
41 lines (25 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include "Grid.h"
// Base Class for All Game Objects ( Belts, danger zones, .. )
class GameObject
{
protected:
CellPosition position; // The current cell position of the GameObject
public:
GameObject(const CellPosition & pos); // Constructor for initializing data members
CellPosition GetPosition() const; // A Getter for position
// ============ Virtual Functions ============
virtual void Draw(Output* pOut) const = 0; // Draws the game object in the window in his position cell
// (drawing depends on GameObject Type, so virtual)
virtual void Apply(Grid* pGrid, Player* pPlayer) = 0; // Applys the effect of the GameObject on the passed Player
// (The effect depends on the GameObject type, so virtual)
// For example, applying a belt is by moving player to the
// end of the belt, and so on
// The following functions are examples of what should be supported by the GameObject class
// They should be overridden by each inherited class
/// TODO::Decide the parameters that you should pass to each function
//Uncomment those functions and implement them in all the derived classes
virtual void Save(ofstream &OutFile,string file) = 0; // Saves the GameObject parameters to the file
virtual void Load(ifstream &Infile,string file) = 0; // Loads and Reads the GameObject parameters from the file
virtual ~GameObject(); // Virtual destructor
};