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
|
#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H
// Programmer: Brett Weiland
// Date: 4/30/23
// File: gameObject.h
// Assignment: SP-B-finalProject
// Purpose: defines the object that all city participants are derived from.
#include <cstddef>
#include "coordinate.h"
class city;
//this is the class all objects are derived from when they want to participate in the city map.
class gameObject {
public:
//Desc: gets the coordinate of this object.
//Pre: none
//Post: coordinate returned
coordinate getLocation() const;
//Desc: records the map we're a part of, as well as our initial position.
//Pre: a pointer to the city, as well as starting position passed.
//Post: object is set to active, initial position set, pointer to the map added
void includeInMap(city *parent_city, coordinate starting_pos);
//Desc: shall return the icon of the object as shown on the rendered map.
//Pre: none
//Post: returns single character for map tileset
virtual char getIcon() const = 0;
//Desc: gets priority of who should be drawn on rendered map if gameObjects are in same position.
// lower values mean they are more likely to be seen.
//Pre: none
//Post: must return a single character to resemble this object
virtual unsigned int get_drawPriority() const = 0;
//Desc: tells city if we are attached to the map, see descriptoin on attached_to_map
//Pre: none
//Post: item is no longer attached to map; see description
bool is_attached() const;
//getters and setters
gameObject *get_top() const;
gameObject *get_bottom() const;
void set_top(gameObject *top);
void set_bottom(gameObject *bottom);
protected:
city *parentCity; //city were a part of
coordinate location; //our location
//if this is false, the gameObject is assumed to be removed from the map,
//meaning the object can't be found by coordinates and is assumed invisible,
//and calls to move() will be skipped if derived class is NPC.
//used for jewl, figured I'd include it as part of the base class due to it's potential uses.
bool attached_to_map = true;
//these are used to keep track of who is over/under us on the same coordinates.
//I would have liked to make this part of the city class and never touch this,
//as that seems more polymorphic. However, I ran short on time.
//set to NULL if no object above/below.
gameObject *top_obj = NULL;
gameObject *bottom_obj = NULL;
//Desc: attaches or detaches us from city, notifies city of our existance.
// See is_attached for implications
//Pre: none
//Post: attached set to true, added to map
void mapAttach();
//Desc: detaches us from city, notifies city to remove us from map.
//Pre: none
//Post: removes from parent map, attached_to_map is false. We are still a part of the city
void mapDetach();
};
#endif
|