Major refactoring - moved constants around, made graph class more graphy, put things where they belong. Simplified a lot of code that I wrote when I wasn't thinking clearly, apparently.
This commit is contained in:
16
gamecore.cpp
16
gamecore.cpp
@ -1,8 +1,10 @@
|
||||
#include "gamecore.h"
|
||||
#include "drawutils.h"
|
||||
#include "mathutils.h"
|
||||
#include "debug.h"
|
||||
|
||||
int GameCore::NODE_SIZE = 25;
|
||||
int GameCore::MAX_MOVE_DISTANCE = 100;
|
||||
int GameCore::NODE_RADIUS = 12;
|
||||
|
||||
GameCore::GameCore()
|
||||
{
|
||||
@ -73,14 +75,14 @@ void GameCore::render()
|
||||
{
|
||||
Vertex* v = graph.get_current_vertex();
|
||||
DrawUtils::draw_circle_filled(display, v->x, v->y,
|
||||
Graph::MAX_MOVE_DISTANCE, 0xcb1919, 128);
|
||||
MAX_MOVE_DISTANCE, 0xcb1919, 128);
|
||||
}
|
||||
|
||||
for (list<Vertex*>::iterator cursor = vertices.begin();
|
||||
cursor != vertices.end(); cursor++)
|
||||
{
|
||||
Vertex v = *(*cursor);
|
||||
DrawUtils::draw_circle_filled(display, v.x, v.y, NODE_SIZE>>1,
|
||||
DrawUtils::draw_circle_filled(display, v.x, v.y, NODE_RADIUS,
|
||||
0x000000);
|
||||
}
|
||||
|
||||
@ -118,5 +120,11 @@ void GameCore::on_exit()
|
||||
|
||||
void GameCore::on_lbutton_down(int x, int y)
|
||||
{
|
||||
graph.do_vertex(x, y, NODE_SIZE);
|
||||
Vertex* cv = graph.get_current_vertex();
|
||||
if (cv != NULL &&
|
||||
(MathUtils::distance(cv->x, cv->y, x, y)
|
||||
> MAX_MOVE_DISTANCE))
|
||||
return;
|
||||
|
||||
graph.do_vertex(x, y, NODE_RADIUS);
|
||||
}
|
||||
|
Reference in New Issue
Block a user