Added display showing information about selected vertex
This commit is contained in:
30
game.cpp
30
game.cpp
@ -85,9 +85,9 @@ void Game::render()
|
||||
v->colour);
|
||||
DrawUtils::draw_text(display,
|
||||
"str " + itos(data.calculate_strength(v)),
|
||||
v->x, v->y, font, 0, 0);
|
||||
v->x, v->y, font);
|
||||
DrawUtils::draw_text(display, "hp " + itos(v->score),
|
||||
v->x, v->y + 13, font, 0, 0);
|
||||
v->x, v->y + 13, font);
|
||||
|
||||
|
||||
for (list<Vertex*>::iterator subcursor = v->neighbors.begin();
|
||||
@ -99,17 +99,40 @@ void Game::render()
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, ring the selected vertex
|
||||
// Finally, ring the selected vertex and write info about it
|
||||
if (data.get_current_vertex() != NULL)
|
||||
{
|
||||
Vertex* v = data.get_current_vertex();
|
||||
DrawUtils::draw_circle(display, v->x, v->y, v->r + 5, 0x000000);
|
||||
draw_stats(v);
|
||||
}
|
||||
|
||||
SDL_Flip(display);
|
||||
}
|
||||
|
||||
|
||||
void Game::draw_stats(Vertex* v)
|
||||
{
|
||||
int num_lines = 4;
|
||||
int x = 20;
|
||||
int y = display->h - (num_lines * 14) - 20;
|
||||
|
||||
DrawUtils::draw_text(display, "player:", x, y, font);
|
||||
|
||||
DrawUtils::draw_text(display, "str:", x, y + 14, font);
|
||||
DrawUtils::draw_text(display, itos(data.calculate_strength(v)),
|
||||
x + 50, y + 14, font);
|
||||
|
||||
DrawUtils::draw_text(display, "def:", x, y + 28, font);
|
||||
DrawUtils::draw_text(display, itos(data.calculate_strength(v)),
|
||||
x + 50, y + 28, font);
|
||||
|
||||
DrawUtils::draw_text(display, "hp:", x, y + 42, font);
|
||||
DrawUtils::draw_text(display, itos(v->score), x + 50, y + 42, font);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Game::on_lbutton_down(int x, int y)
|
||||
{
|
||||
if (!data.endgame()) data.handle_click(x, y);
|
||||
@ -128,4 +151,5 @@ void Game::on_key_down(SDLKey sym, SDLMod mod, Uint16 unicode)
|
||||
if (sym == SDLK_a) data.set_mode(MODE_ATTACK);
|
||||
if (sym == SDLK_m) data.set_mode(MODE_MOVE);
|
||||
if (sym == SDLK_b) data.set_mode(MODE_BUILD);
|
||||
if (sym == SDLK_s) data.set_mode(MODE_SELECT);
|
||||
}
|
||||
|
Reference in New Issue
Block a user