Fixed first vertex bug, use pointers to track vertices (in case we want to move them easily later), and added a formula for vertex distance calculations

This commit is contained in:
2011-06-22 21:54:35 -04:00
parent bbae7690f4
commit 53f1560393
5 changed files with 78 additions and 29 deletions

View File

@ -67,13 +67,13 @@ void GameCore::render()
{
DrawUtils::draw(display, background, 0, 0);
list<Vertex> vertices = graph.get_vertices();
list<Vertex*> vertices = graph.get_vertices();
list<Edge> edges = graph.get_edges();
for (list<Vertex>::iterator cursor = vertices.begin();
for (list<Vertex*>::iterator cursor = vertices.begin();
cursor != vertices.end(); cursor++)
{
Vertex v = *cursor;
Vertex v = *(*cursor);
DrawUtils::draw(display, node, v.x_min, v.y_min);
}
@ -81,7 +81,8 @@ void GameCore::render()
cursor != edges.end(); cursor++)
{
Edge e = *cursor;
DrawUtils::draw_line(e.a.x, e.a.y, e.b.x, e.b.y, 2, 0x000000, display);
DrawUtils::draw_line(display, e.a->x, e.a->y, e.b->x, e.b->y, 2,
0x000000);
}
SDL_Flip(display);