From b5e385586dfc8e9c2d8a68fe7b8d96115a39447b Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Wed, 22 Jun 2011 23:52:22 -0400 Subject: [PATCH] Replaced move_template with procedural circle primitive - but it won't fill or alphatize yet. --- drawutils.cpp | 33 +++++++++++++++++++++++++++++++++ drawutils.h | 1 + gamecore.cpp | 5 ++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/drawutils.cpp b/drawutils.cpp index 63877c0..fd3ce64 100644 --- a/drawutils.cpp +++ b/drawutils.cpp @@ -89,6 +89,39 @@ void DrawUtils::draw_line(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Si } +void DrawUtils::draw_circle_filled(SDL_Surface* dest, Sint16 int_x, Sint16 int_y, Uint16 int_r, Uint32 colour, Uint8 alpha) +{ + float x = static_cast (int_x); + float y = static_cast (int_y); + float r = static_cast (int_r); + + SDL_Rect pen; + pen.w = 2; + pen.h = 2; + + 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); + // pen.w = static_cast (2 + cos(i) * r); + // pen.h = static_cast (2 + sin(i) * r); + + 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, alpha)); + } +} + + + bool DrawUtils::transpare(SDL_Surface* surface, int r, int g, int b) { if (surface == NULL) return false; diff --git a/drawutils.h b/drawutils.h index cfe2ec1..238cc68 100644 --- a/drawutils.h +++ b/drawutils.h @@ -18,6 +18,7 @@ class DrawUtils static bool draw(SDL_Surface* dest, SDL_Surface* drawable, int x, int y, 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_filled(SDL_Surface* dest, Sint16 x, Sint16 y, Uint16 r, Uint32 colour, Uint8 alpha = 255); // transpare (v) - to make transparent static bool transpare(SDL_Surface* surface, int r, int g, int b); diff --git a/gamecore.cpp b/gamecore.cpp index a9c782e..e736a29 100644 --- a/gamecore.cpp +++ b/gamecore.cpp @@ -91,9 +91,8 @@ void GameCore::render() if (graph.get_current_vertex() != NULL) { Vertex* v = graph.get_current_vertex(); - DrawUtils::draw(display, move_template, - v->x - Graph::MAX_MOVE_DISTANCE, - v->y - Graph::MAX_MOVE_DISTANCE); + DrawUtils::draw_circle_filled(display, v->x, v->y, + Graph::MAX_MOVE_DISTANCE, 0xcb1919, 128); }