diff --git a/drawutils.cpp b/drawutils.cpp index 64ab53b..8c267a8 100644 --- a/drawutils.cpp +++ b/drawutils.cpp @@ -173,8 +173,6 @@ void DrawUtils::draw_text(SDL_Surface* display, string text, int x, int y, return; } - transpare(surface); - /* Blit the surface */ dest.x = (center_x ? (display->w - surface->w) / 2 : x); dest.y = (center_y ? (display->h - surface->h) / 2 : y); @@ -184,3 +182,33 @@ void DrawUtils::draw_text(SDL_Surface* display, string text, int x, int y, SDL_BlitSurface(surface, NULL, display, &dest); SDL_FreeSurface(surface); } + + +void DrawUtils::draw_circle(SDL_Surface* dest, Sint16 int_x, Sint16 int_y, + Uint16 int_r, Uint32 colour) +{ + float x = static_cast (int_x); + float y = static_cast (int_y); + float r = static_cast (int_r); + + SDL_Rect pen; + float i; + + for (i=0; i < 6.28318531; i += 0.0034906585) + { + pen.x = static_cast (x + cos(i) * r); + pen.y = static_cast (y + sin(i) * r); + int w = 2; + int h = 2; + + if (pen.x >= dest->clip_rect.x && + pen.y >= dest->clip_rect.y && + pen.x + pen.w <= dest->clip_rect.w && + pen.y + pen.h <= dest->clip_rect.h) + SDL_FillRect(dest, &pen, + SDL_MapRGBA(dest->format, + (colour >> 16) & 0xff, + (colour >> 8) & 0xff, + colour & 0xff, 1)); + } +} diff --git a/drawutils.h b/drawutils.h index 7fa48c9..b13da38 100644 --- a/drawutils.h +++ b/drawutils.h @@ -21,6 +21,7 @@ class DrawUtils int x2, int y2, int w, int h); static void draw_line(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint16 width, Uint32 colour); + static void draw_circle(SDL_Surface* dest, Sint16 x, Sint16 y, Uint16 r, Uint32 colour); 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, diff --git a/game.cpp b/game.cpp index 3ba4b33..485247b 100644 --- a/game.cpp +++ b/game.cpp @@ -99,6 +99,13 @@ void Game::render() } } + // Finally, ring the selected vertex + if (data.get_current_vertex() != NULL) + { + Vertex* v = data.get_current_vertex(); + DrawUtils::draw_circle(display, v->x, v->y, v->r + 5, 0x000000); + } + SDL_Flip(display); }