summaryrefslogtreecommitdiffstats
path: root/Room.h
diff options
context:
space:
mode:
Diffstat (limited to 'Room.h')
-rw-r--r--Room.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/Room.h b/Room.h
index c9f5dcb..c2d96d9 100644
--- a/Room.h
+++ b/Room.h
@@ -3,10 +3,12 @@
#include "Polygon.h"
#include "LevelObject.h"
+#include "VertexProvider.h"
+#include "LevelVertex.h"
#include <string>
-class Room : public Polygon, public LevelObject {
+class Room : public Polygon, public LevelObject, public VertexProvider {
private:
std::string name;
float height;
@@ -22,9 +24,18 @@ class Room : public Polygon, public LevelObject {
float getHeight() const {return height;}
void setHeight(float height) {this->height = height;}
- virtual bool hit(const Vertex &v) const {return contains(v);}
+ virtual bool hit(const Vertex &v, float scale) const {return contains(v);}
virtual int getPriority() const {return 0;}
+ virtual std::vector<SharedPtr<LevelObject> > getChildren() {
+ std::vector<SharedPtr<LevelObject> > children;
+
+ for(size_t i = 0; i < size(); i++)
+ children.push_back(SharedPtr<LevelObject>(new LevelVertex(this, i)));
+
+ return children;
+ }
+
virtual const char* getType() const {
return "Room";
}
@@ -56,6 +67,31 @@ class Room : public Polygon, public LevelObject {
return ret / size();
}
+
+ virtual const Vertex* getVertex(size_t id) const {
+ return &at(id);
+ }
+
+ virtual size_t getVertexCount() const {
+ return size();
+ }
+
+ virtual void moveVertex(size_t id, float x, float y) {
+ at(id) += Vertex(x, y);
+ }
+
+ virtual void rotateVertex(size_t id, float a) {
+ Vertex z = at(id);
+ float s = sinf(a);
+ float c = cosf(a);
+
+ for(iterator v = begin(); v != end(); v++) {
+ *v -= z;
+ v->setLocation(c*v->getX() - s*v->getY(), c*v->getY() + s*v->getX());
+ *v += z;
+ }
+ }
+
};
#endif /*ROOM_H_*/