From afa02f645056c5823b0d8a29d37c1ff10aedce7a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Feb 2024 21:53:44 -0600 Subject: init --- gameObject.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 gameObject.h (limited to 'gameObject.h') diff --git a/gameObject.h b/gameObject.h new file mode 100644 index 0000000..81a353b --- /dev/null +++ b/gameObject.h @@ -0,0 +1,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 +#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 -- cgit v1.2.3