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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H
#include "../presentation/BitmapStore.h"
#include "../logic/Maze.h"
/**
* @brief Parent class for objects that are placed in the maze.
*
* These objects are one maze block big. The image in the bitmap store will be drawn
* on the screen every frame at the Screen class's discression, being rotated to face
* in the 'facing' direction. Coordinates are given in terms of the Maze class's coordinate
* system. For example, increasing the x coordinate of an object by 1 will move it one maze
* block to the right. The number of pixels that this corresponds to is handled by the
* Screen class.
*
* When an object is in a situation that it should be destroyed, it is marked for destruction.
* It is then the responsibility of the Game class to actually destroy it.
*
* @author Justin Wernick
* @author David Schneider
*/
class GameObject
{
public:
/**
* @brief Creates a GameObject with the given parameters.
*
* @param [in] x The x coordinate of the new object.
* @param [in] y The y coordinate of the new object.
* @param [in] image The image that is drawn to represent the object.
* @param [in] facing The direction that the object is facing. If the object has no direction,
* such as with Checkpoint or Rock, the default value of Maze::UP should be used.
*/
GameObject(double x, double y, BitmapStore::Image image, Maze::Direction facing=Maze::UP);
//assignment and copy constructors have been left with the compiler generated versions
/**
* @brief Provides access to the x coordinate of the object.
*
* @return The x coordinate of the object, in maze blocks, where 0 is the far left column of the maze.
*/
double x() const;
/**
* @brief Provides access to the y coordinate of the object.
*
* @return The y coordinate of the object, in maze blocks, where 0 is the top row of the maze.
*/
double y() const;
/**
* @brief Checks if an object has been marked for destruction, for example through a collision.
*
* @return True is the object has been marked for destruction, false otherwise.
*/
bool destroyed() const;
/**
* @brief Provides access to the image that should be drawn to represent the object.
*
* @return An image, corresponding to an enumerated type that can be converted into a bitmap by the BitmapStore class.
*/
BitmapStore::Image image() const;
/**
* @brief Provides access to the direction that the object is facing.
*
* @return A direction, corresponding to the rotation that should be done to the drawn image and, in the case of Cars, the direction that they move forward.
*/
Maze::Direction facing() const;
protected:
double _x; ///< The x coordinate of the object's position.
double _y; ///< The y coordinate of the object's position.
bool _destroyed; ///< True if the object has been marked for destruction.
BitmapStore::Image _image; ///< The bitmap that should be drawn on the screen to represent the object.
Maze::Direction _facing; ///< The direction in which the object is facing, up, down, left, or right.
};
#endif // GAMEOBJECT_H
|