Change text over nodes to just be hit points
This commit is contained in:
parent
a2f36a447b
commit
2bdc7e0e59
|
@ -152,15 +152,16 @@ bool DrawUtils::transpare(SDL_Surface* surface, int r, int g, int b)
|
|||
// Modified from
|
||||
// http://www.parallelrealities.co.uk/tutorials/basic/tutorial7.php
|
||||
void DrawUtils::draw_text(SDL_Surface* display, string text, int x, int y,
|
||||
TTF_Font *font)
|
||||
TTF_Font *font, unsigned int colour,
|
||||
bool center_x, bool center_y)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
SDL_Surface *surface;
|
||||
SDL_Color color;
|
||||
|
||||
color.r = 0;
|
||||
color.g = 0;
|
||||
color.b = 0;
|
||||
color.r = (colour >> 16) & 0xff;
|
||||
color.g = (colour >> 8) & 0xff;
|
||||
color.b = colour & 0xff;
|
||||
|
||||
surface = TTF_RenderUTF8_Blended(font, text.c_str(), color);
|
||||
|
||||
|
@ -174,8 +175,8 @@ void DrawUtils::draw_text(SDL_Surface* display, string text, int x, int y,
|
|||
}
|
||||
|
||||
/* Blit the surface */
|
||||
dest.x = x;
|
||||
dest.y = y;
|
||||
dest.x = center_x ? x - (surface->w / 2) : x;
|
||||
dest.y = center_y ? y - (surface->h / 2) : y;
|
||||
dest.w = surface->w;
|
||||
dest.h = surface->h;
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ class DrawUtils
|
|||
static void draw_circle_filled(SDL_Surface* dest, Sint16 x, Sint16 y, Uint16 r, Uint32 colour);
|
||||
|
||||
static void draw_text(SDL_Surface* display, string text, int x, int y,
|
||||
TTF_Font *font);
|
||||
TTF_Font *font, unsigned int colour = 0x000000,
|
||||
bool center_x = false, bool center_y = false);
|
||||
|
||||
// transpare (v) - to make transparent
|
||||
// this function makes a particular color key on a surface transparent
|
||||
|
|
16
game.cpp
16
game.cpp
|
@ -83,12 +83,6 @@ void Game::render()
|
|||
Vertex* v = *cursor;
|
||||
DrawUtils::draw_circle_filled(display, v->x, v->y, v->r,
|
||||
v->colour);
|
||||
DrawUtils::draw_text(display,
|
||||
"str " + itos(data.calculate_strength(v)),
|
||||
v->x, v->y, font);
|
||||
DrawUtils::draw_text(display, "hp " + itos(v->score),
|
||||
v->x, v->y + 13, font);
|
||||
|
||||
|
||||
for (list<Vertex*>::iterator subcursor = v->neighbors.begin();
|
||||
subcursor != v->neighbors.end(); subcursor++)
|
||||
|
@ -99,6 +93,16 @@ void Game::render()
|
|||
}
|
||||
}
|
||||
|
||||
// Add hit points on top of the nodes
|
||||
for (list<Vertex*>::iterator cursor = vertices.begin();
|
||||
cursor != vertices.end(); cursor++)
|
||||
{
|
||||
Vertex* v = *cursor;
|
||||
|
||||
DrawUtils::draw_text(display, itos(v->score), v->x, v->y, font,
|
||||
0x00ff00, true, true);
|
||||
}
|
||||
|
||||
// Finally, ring the selected vertex and write info about it
|
||||
if (data.get_current_vertex() != NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user