Use vertex's individual radius for all relevant calculations

This commit is contained in:
Anna Rose 2011-06-23 12:46:32 -04:00
parent 4b1947fe44
commit fc71203220
4 changed files with 14 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@ -37,7 +37,7 @@ bool GameCore::init()
{ {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) return false; if (SDL_Init(SDL_INIT_EVERYTHING) < 0) return false;
display = SDL_SetVideoMode(800,600,32, SDL_HWSURFACE | SDL_DOUBLEBUF); display = SDL_SetVideoMode(1024,768,32, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (display == NULL) if (display == NULL)
{ {
#ifdef DEBUG #ifdef DEBUG
@ -82,7 +82,7 @@ void GameCore::render()
cursor != vertices.end(); cursor++) cursor != vertices.end(); cursor++)
{ {
Vertex v = *(*cursor); Vertex v = *(*cursor);
DrawUtils::draw_circle_filled(display, v.x, v.y, NODE_RADIUS, DrawUtils::draw_circle_filled(display, v.x, v.y, v.r,
0x000000); 0x000000);
} }
@ -124,7 +124,10 @@ void GameCore::on_lbutton_down(int x, int y)
if (cv != NULL && if (cv != NULL &&
(MathUtils::distance(cv->x, cv->y, x, y) (MathUtils::distance(cv->x, cv->y, x, y)
> MAX_MOVE_DISTANCE)) > MAX_MOVE_DISTANCE))
{
graph.select_vertex(x, y);
return; return;
}
graph.do_vertex(x, y, NODE_RADIUS); graph.do_vertex(x, y, NODE_RADIUS);
} }

View File

@ -72,3 +72,11 @@ void Graph::add_vertex(int x, int y, int r)
edges.push_back(e); edges.push_back(e);
current_vertex = v; current_vertex = v;
} }
Vertex::Vertex(int x, int y, int r)
{
this->x = x;
this->y = y;
this->r = r;
}

View File

@ -14,8 +14,7 @@ using std::list;
class Vertex class Vertex
{ {
public: public:
Vertex(int x, int y, int r) Vertex(int x, int y, int r);
{ this->x = x; this->y = y; }
int x; int x;
int y; int y;