First implementation of game logic and control
This commit is contained in:
18
graph.cpp
18
graph.cpp
@ -25,12 +25,24 @@ bool Graph::vertex_present(int x, int y, int size)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Graph::add_vertex(Vertex v)
|
||||
void Graph::add_vertex(int x, int y, int size)
|
||||
{
|
||||
if (vertex_present(v.x, v.y)) return;
|
||||
Vertex v;
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
|
||||
v.x_min = x - size/2;
|
||||
v.x_max = x + size/2;
|
||||
v.y_min = y - size/2;
|
||||
v.y_max = y + size/2;
|
||||
|
||||
if (vertex_present(v.x, v.y, 25)) return;
|
||||
|
||||
vertices.push_back(v);
|
||||
edges.push_back(Edge(last_vertex, v));
|
||||
Edge e;
|
||||
e.a = last_vertex;
|
||||
e.b = v;
|
||||
edges.push_back(e);
|
||||
last_vertex = v;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user