Added transparency to nodes
This commit is contained in:
parent
fc08adcade
commit
fc8a76c1db
|
@ -87,3 +87,13 @@ void DrawUtils::draw_line(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint16 wid
|
||||||
cy += dy;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -13,10 +13,14 @@ class DrawUtils
|
||||||
public:
|
public:
|
||||||
DrawUtils() {}
|
DrawUtils() {}
|
||||||
static SDL_Surface* load(string file);
|
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);
|
||||||
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);
|
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);
|
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
|
#endif
|
||||||
|
|
|
@ -47,7 +47,9 @@ bool GameCore::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
background = DrawUtils::load("background.bmp");
|
background = DrawUtils::load("background.bmp");
|
||||||
|
|
||||||
node = DrawUtils::load("node.bmp");
|
node = DrawUtils::load("node.bmp");
|
||||||
|
DrawUtils::transpare(node, 255, 0, 255);
|
||||||
|
|
||||||
if (background == NULL || node == NULL)
|
if (background == NULL || node == NULL)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +65,8 @@ bool GameCore::init()
|
||||||
|
|
||||||
void GameCore::render()
|
void GameCore::render()
|
||||||
{
|
{
|
||||||
|
DrawUtils::draw(display, background, 0, 0);
|
||||||
|
|
||||||
list<Vertex> vertices = graph.get_vertices();
|
list<Vertex> vertices = graph.get_vertices();
|
||||||
list<Edge> edges = graph.get_edges();
|
list<Edge> edges = graph.get_edges();
|
||||||
|
|
||||||
|
@ -77,7 +81,7 @@ void GameCore::render()
|
||||||
cursor != edges.end(); cursor++)
|
cursor != edges.end(); cursor++)
|
||||||
{
|
{
|
||||||
Edge e = *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);
|
SDL_Flip(display);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user