Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.
Kyle Martin edited this page Jun 24, 2017 · 2 revisions

The Entity object is one of the defining characteristic of EMA, allowing for any object derived from this to be organized within the API and updated.

The definition of the entity class is simple:

class Entity
{
    friend class Bin;
public:
    //Simple Constructor
    Entity(const unsigned int x, const unsigned int y);

    virtual void update() = 0;

    //Deconstructor for derived classes
    virtual ~Entity();

    unsigned int getX() const;

    unsigned int getY() const;

protected:
    // X/Y Locations
    unsigned int x;
    unsigned int y;
};

Notice that update is pure virtual - this is because every tick, the game will call every object's update function.. This is the only hook that object has in the world: if the object does not update, and nothing acts on it, nothing will ever happen to this object.

The object also has an X/Y location in the world.. You can change this all you want, however you need to call the Bin's move(Entity*, unsigned int newX, unsigned int newY) function so that the move and can be properly tracked (so the getNear function series will work properly, and efficiently.

Clone this wiki locally