summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Portal.h3
-rw-r--r--Renderer.cpp34
-rw-r--r--Renderer.h3
-rw-r--r--Room.h8
4 files changed, 42 insertions, 6 deletions
diff --git a/Portal.h b/Portal.h
index a4cb349..3df4247 100644
--- a/Portal.h
+++ b/Portal.h
@@ -57,8 +57,7 @@ class Portal : public LevelObject {
}
virtual void move(float x, float y) {
- pos.setX(pos.getX()+x);
- pos.setY(pos.getY()+y);
+ pos += Vertex(x, y);
}
virtual void rotate(float a) {
diff --git a/Renderer.cpp b/Renderer.cpp
index c8ecac2..e2ededc 100644
--- a/Renderer.cpp
+++ b/Renderer.cpp
@@ -69,6 +69,15 @@ void Renderer::drawCircle(const Vertex &m, float r, int n) {
glEnd();
}
+void Renderer::fillCircle(const Vertex &m, float r, int n) {
+ glBegin(GL_POLYGON);
+
+ for(int i = 0; i < n; i++)
+ glVertex2f(m.getX()+r*cosf(2*M_PI*i/n), m.getY()+r*sinf(2*M_PI*i/n));
+
+ glEnd();
+}
+
void Renderer::drawCross(const Vertex &m, float r) {
glBegin(GL_LINES);
@@ -90,6 +99,15 @@ void Renderer::renderObject(const LevelObject &object, bool selected, bool highl
renderPortal(*(Portal*)&object, selected, highlighted, scale);
}
+void Renderer::renderVertex(const Vertex &vertex, bool selected, bool highlighted, float scale) {
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+ fillCircle(vertex, 3/scale, 16);
+
+ glLineWidth(1.0f);
+ glColor4f(9.0f, 0.7f, 0.0f, 0.9f);
+ drawCircle(vertex, 3/scale, 16);
+}
+
void Renderer::renderRoom(const Room &room, bool selected, bool highlighted, float scale) {
if(selected)
glColor4f(0.0f, 0.7f, 1.0f, 0.2f);
@@ -112,6 +130,11 @@ void Renderer::renderRoom(const Room &room, bool selected, bool highlighted, flo
}
drawPolygon(room);
+
+ if(selected || highlighted) {
+ for(Room::const_iterator v = room.begin(); v != room.end(); v++)
+ renderVertex(*v, false, false, scale);
+ }
}
void Renderer::renderPlayerStart(const PlayerStart &start, bool selected, bool highlighted, float scale) {
@@ -169,6 +192,17 @@ void Renderer::renderPortal(const Portal &portal, bool selected, bool highlighte
glVertex2f(portal.getPosition().getX()+x, portal.getPosition().getY()+y);
glEnd();
+
+ if(highlighted || selected) {
+ renderVertex(Vertex(portal.getPosition().getX()-x+ts, portal.getPosition().getY()-y-tc),
+ false, false, scale);
+ renderVertex(Vertex(portal.getPosition().getX()-x-ts, portal.getPosition().getY()-y+tc),
+ false, false, scale);
+ renderVertex(Vertex(portal.getPosition().getX()+x+ts, portal.getPosition().getY()+y-tc),
+ false, false, scale);
+ renderVertex(Vertex(portal.getPosition().getX()+x-ts, portal.getPosition().getY()+y+tc),
+ false, false, scale);
+ }
}
void Renderer::render(const Level &level, const Rectangle &rect, float scale) {
diff --git a/Renderer.h b/Renderer.h
index 38c822d..0208517 100644
--- a/Renderer.h
+++ b/Renderer.h
@@ -19,11 +19,14 @@ class Renderer {
protected:
void fillPolygon(const Polygon &polygon);
void drawPolygon(const Polygon &polygon, bool close = true);
+ void fillCircle(const Vertex &m, float r, int n = 64);
void drawCircle(const Vertex &m, float r, int n = 64);
void drawCross(const Vertex &m, float r);
void renderObject(const LevelObject &object, bool selected, bool highlighted, float scale);
+ void renderVertex(const Vertex &vertex, bool selected, bool highlighted, float scale);
+
void renderRoom(const Room &room, bool selected, bool highlighted, float scale);
void renderPlayerStart(const PlayerStart &start, bool selected, bool highlighted, float scale);
void renderPortal(const Portal &portal, bool selected, bool highlighted, float scale);
diff --git a/Room.h b/Room.h
index 1cac5d9..c9f5dcb 100644
--- a/Room.h
+++ b/Room.h
@@ -30,10 +30,10 @@ class Room : public Polygon, public LevelObject {
}
virtual void move(float x, float y) {
- for(iterator v = begin(); v != end(); v++) {
- v->setX(v->getX()+x);
- v->setY(v->getY()+y);
- }
+ Vertex m(x, y);
+
+ for(iterator v = begin(); v != end(); v++)
+ *v += m;
}
virtual void rotate(float a) {