Commit 89551e86 authored by Stuart John Watson's avatar Stuart John Watson

Added std::ostream print formatter for Entity

	modified:   src/entity/entity.cpp
	modified:   src/entity/entity.h
parent 68c4cac1
......@@ -31,6 +31,10 @@ int Entity::moveTo(int _x,int _y){
}
}
std::tuple<int,int> const Entity::getPosition(){
return std::make_tuple(x,y);
}
void Entity::draw(Display*& dpy,Window& w,GC& gc,int scale){
Colormap colormap;
colormap = DefaultColormap(dpy, 0);
......@@ -39,3 +43,9 @@ void Entity::draw(Display*& dpy,Window& w,GC& gc,int scale){
}
void Entity::turn(){}
std::ostream& operator<<(std::ostream& os, Entity &o){
std::tuple<int,int> p = o.getPosition();
os << "<Entity:" << std::get<0>(p) << "," << std::get<1>(p) << ">";
return os;
}
......@@ -16,6 +16,8 @@ class Entity {
void draw(Display*&,Window&,GC&,int); // Draw state
virtual void turn();
std::tuple<int,int> const getPosition();
protected:
int moveTo(int,int); // Move to these coordinates
......@@ -30,5 +32,6 @@ class Entity {
};
std::ostream& operator<<(std::ostream&, Entity&);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment