Fixed bugs with the move template

This commit is contained in:
Anna Rose 2011-06-22 22:39:37 -04:00
parent 48c45c2191
commit 5b53e0b115

View File

@ -51,13 +51,8 @@ bool GameCore::init()
} }
background = DrawUtils::load("background.bmp"); background = DrawUtils::load("background.bmp");
node = DrawUtils::load("node.bmp"); node = DrawUtils::load("node.bmp");
DrawUtils::transpare(node, 255, 0, 255); move_template = DrawUtils::load("mvtemplate.bmp");
move_template = DrawUtils::load("move_template.bmp");
DrawUtils::transpare(move_template, 255, 0, 255);
SDL_SetAlpha(move_template, SDL_SRCALPHA, 128);
if (background == NULL || node == NULL || move_template == NULL) if (background == NULL || node == NULL || move_template == NULL)
{ {
@ -67,6 +62,10 @@ bool GameCore::init()
return false; return false;
} }
DrawUtils::transpare(node, 255, 0, 255);
DrawUtils::transpare(move_template, 255, 0, 255);
SDL_SetAlpha(move_template, SDL_SRCALPHA, 128);
return true; return true;
} }
@ -96,7 +95,8 @@ void GameCore::render()
if (graph.get_current_vertex() != NULL) if (graph.get_current_vertex() != NULL)
{ {
Vertex* v = graph.get_current_vertex(); Vertex* v = graph.get_current_vertex();
DrawUtils::draw(display, move_template, v->x, v->y); DrawUtils::draw(display, move_template, v->x - MAX_MOVE_DISTANCE / 2,
v->y - MAX_MOVE_DISTANCE / 2);
} }
@ -133,7 +133,7 @@ void GameCore::on_lbutton_down(int x, int y)
new_v.y = y; new_v.y = y;
if (v != NULL && (Vertex::distance(*v, new_v) > MAX_MOVE_DISTANCE)) if (v != NULL && (Vertex::distance(*v, new_v) > MAX_MOVE_DISTANCE))
return return;
graph.do_vertex(x, y, NODE_SIZE); graph.do_vertex(x, y, NODE_SIZE);
} }