diff --git a/src/main.c b/src/main.c index de0bce5..43e6e06 100644 --- a/src/main.c +++ b/src/main.c @@ -211,6 +211,7 @@ static void update_space(void) { // Blitting order. (layers) // // BG | Stars and planets. +// | Background player stuff (planet targetting) // | Background particles. // | Back layer weapons. // X @@ -226,6 +227,7 @@ static void render_space(void) { // BG. space_render(dt); planets_render(); + player_renderBG(); weapons_render(WEAPON_LAYER_BG); // N. pilots_render(); diff --git a/src/player.c b/src/player.c index c848add..6d64983 100644 --- a/src/player.c +++ b/src/player.c @@ -209,13 +209,38 @@ void player_message(const char* fmt, ...) { msg_stack[0].t = SDL_GetTicks() + msg_timeout; } +void player_renderBG(void) { + double x, y; + glColour* c; + Planet* planet; + + if(planet_target >= 0) { + planet = &cur_system->planets[planet_target]; + + if(areEnemies(player->faction, planet->faction)) c = &cHostile; + else c = &cNeutral; + + x = planet->pos.x - planet->gfx_space->sw/2.; + y = planet->pos.y + planet->gfx_space->sh/2.; + gl_blitSprite(gui.gfx_targetPlanet, x, y, 0, 0, c); // Top left. + + x += planet->gfx_space->sw; + gl_blitSprite(gui.gfx_targetPlanet, x, y, 1, 0, c); // Top right. + + y -= planet->gfx_space->sh; + gl_blitSprite(gui.gfx_targetPlanet, x, y, 1, 1, c); // Bottom right. + + x -= planet->gfx_space->sw; + gl_blitSprite(gui.gfx_targetPlanet, x, y, 0, 1, c); // Bottom left. + } +} + // Render the player. void player_render(void) { int i, j; double x, y; char str[10]; Pilot* p; - Planet* planet; glColour* c; glFont* f; @@ -240,27 +265,6 @@ void player_render(void) { x -= p->ship->gfx_space->sw * PILOT_SIZE_APROX; gl_blitSprite(gui.gfx_targetPilot, x, y, 0, 1, c); // Bottom left. } - // Render the planet target graphics. - if(planet_target >= 0) { - planet = &cur_system->planets[planet_target]; - - if(areEnemies(player->faction, planet->faction)) c = &cHostile; - else c = &cNeutral; - - x = p->solid->pos.x - p->ship->gfx_space->sw * PILOT_SIZE_APROX/2.; - y = p->solid->pos.y + p->ship->gfx_space->sh * PILOT_SIZE_APROX/2.; - gl_blitSprite(gui.gfx_targetPlanet, x, y, 0, 0, c); // Top left. - - x += p->ship->gfx_space->sw * PILOT_SIZE_APROX; - gl_blitSprite(gui.gfx_targetPlanet, x, y, 1, 0, c); // Top right. - - y -= p->ship->gfx_space->sh * PILOT_SIZE_APROX; - gl_blitSprite(gui.gfx_targetPlanet, x, y, 1, 1, c); // Bottom right. - - x -= p->ship->gfx_space->sw * PILOT_SIZE_APROX; - gl_blitSprite(gui.gfx_targetPlanet, x, y, 0, 1, c); // Bottom left. - - } // Render the player. pilot_render(player); diff --git a/src/player.h b/src/player.h index 7bb9a04..80e1319 100644 --- a/src/player.h +++ b/src/player.h @@ -27,6 +27,7 @@ void player_new(void); int gui_init(void); void gui_free(void); void player_render(void); +void player_renderBG(void); // Render BG layer. // Misc. void player_message(const char* fmt, ...);