diff --git a/drawutils.cpp b/drawutils.cpp index 33d24f9..0e42991 100644 --- a/drawutils.cpp +++ b/drawutils.cpp @@ -87,3 +87,13 @@ void DrawUtils::draw_line(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint16 wid cy += dy; } } + + +bool DrawUtils::transpare(SDL_Surface* surface, int r, int g, int b) +{ + if (surface == NULL) return false; + + SDL_SetColorKey(surface, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(surface->format, r, g, b)); + + return true; +} diff --git a/drawutils.h b/drawutils.h index bf91073..119dd73 100644 --- a/drawutils.h +++ b/drawutils.h @@ -13,10 +13,14 @@ class DrawUtils public: DrawUtils() {} static SDL_Surface* load(string file); + static bool draw(SDL_Surface* dest, SDL_Surface* drawable, int x, int y); 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(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint16 width, Uint32 colour, SDL_Surface* dest); + + // transpare (v) - to make transparent + static bool transpare(SDL_Surface* surface, int r, int g, int b); }; #endif diff --git a/gamecore.cpp b/gamecore.cpp index 2d68f59..f242b1c 100644 --- a/gamecore.cpp +++ b/gamecore.cpp @@ -47,7 +47,9 @@ bool GameCore::init() } background = DrawUtils::load("background.bmp"); + node = DrawUtils::load("node.bmp"); + DrawUtils::transpare(node, 255, 0, 255); if (background == NULL || node == NULL) { @@ -63,6 +65,8 @@ bool GameCore::init() void GameCore::render() { + DrawUtils::draw(display, background, 0, 0); + list vertices = graph.get_vertices(); list edges = graph.get_edges(); @@ -77,7 +81,7 @@ void GameCore::render() cursor != edges.end(); cursor++) { Edge e = *cursor; - DrawUtils::draw_line(e.a.x, e.a.y, e.b.x, e.b.y, 2, 0xffffff, display); + DrawUtils::draw_line(e.a.x, e.a.y, e.b.x, e.b.y, 2, 0x000000, display); } SDL_Flip(display);