Moved distance limiting code to a smarter location, refactored related code
This commit is contained in:
22
gamecore.cpp
22
gamecore.cpp
@ -3,7 +3,6 @@
|
||||
#include "debug.h"
|
||||
|
||||
int GameCore::NODE_SIZE = 25;
|
||||
int GameCore::MAX_MOVE_DISTANCE = 200;
|
||||
|
||||
GameCore::GameCore()
|
||||
{
|
||||
@ -92,8 +91,9 @@ void GameCore::render()
|
||||
if (graph.get_current_vertex() != NULL)
|
||||
{
|
||||
Vertex* v = graph.get_current_vertex();
|
||||
DrawUtils::draw(display, move_template, v->x - MAX_MOVE_DISTANCE / 2,
|
||||
v->y - MAX_MOVE_DISTANCE / 2);
|
||||
DrawUtils::draw(display, move_template,
|
||||
v->x - Graph::MAX_MOVE_DISTANCE,
|
||||
v->y - Graph::MAX_MOVE_DISTANCE);
|
||||
}
|
||||
|
||||
|
||||
@ -124,21 +124,5 @@ void GameCore::on_exit()
|
||||
|
||||
void GameCore::on_lbutton_down(int x, int y)
|
||||
{
|
||||
Vertex* v = graph.get_current_vertex();
|
||||
Vertex new_v = Vertex();
|
||||
new_v.x = x;
|
||||
new_v.y = y;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (v != NULL)
|
||||
cerr << "debug: GameCore::on_lbutton_down(): distance="
|
||||
<< Vertex::distance(*v, new_v) << "\n";
|
||||
else
|
||||
cerr << "debug: GameCore::on_lbutton_down(): distance=0, current_vertex is NULL\n";
|
||||
#endif
|
||||
|
||||
if (v != NULL && (Vertex::distance(*v, new_v) > MAX_MOVE_DISTANCE))
|
||||
return;
|
||||
|
||||
graph.do_vertex(x, y, NODE_SIZE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user