diff --git a/src/player.c b/src/player.c index ad94ecc..c9f068e 100644 --- a/src/player.c +++ b/src/player.c @@ -567,8 +567,39 @@ void player_renderBG(void) { /* Render the player. */ void player_render(void) { - if((player != NULL) && !player_isFlag(PLAYER_CREATING)) + Pilot* p; + glColour* c; + double x, y; + + if((player != NULL) && !player_isFlag(PLAYER_CREATING)) { + /* Render the player target graphics. */ + if(player_target != PLAYER_ID) p = pilot_get(player_target); + else p = NULL; + if((p == NULL) || pilot_isFlag(p, PILOT_DEAD)) + player_target = PLAYER_ID; /* No more pilot target. */ + else { + /* There is still a pilot target. */ + if(pilot_isDisabled(p)) c = &cInert; + else if(pilot_isFlag(p, PILOT_HOSTILE)) 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_targetPilot, x, y, 0, 0, c); /* Top left. */ + + x += p->ship->gfx_space->sw * PILOT_SIZE_APROX; + gl_blitSprite(gui.gfx_targetPilot, x, y, 1, 0, c); /* Top right. */ + + y -= p->ship->gfx_space->sh * PILOT_SIZE_APROX; + gl_blitSprite(gui.gfx_targetPilot, x, y, 1, 1, c); /* Bottom right. */ + + x -= p->ship->gfx_space->sw * PILOT_SIZE_APROX; + gl_blitSprite(gui.gfx_targetPilot, x, y, 0, 1, c); /* Bottom left. */ + } + + /* Player is ontop of targeting graphic. */ pilot_render(player); + } } /* Render the player's GUI. */ @@ -598,31 +629,7 @@ void player_renderGUI(void) { } if(player == NULL) return; - /* Render the player target graphics. */ - if(player_target != PLAYER_ID) p = pilot_get(player_target); - else p = NULL; - if((p == NULL) || pilot_isFlag(p, PILOT_DEAD)) - player_target = PLAYER_ID; /* No more pilot target. */ - else { - /* There is still a pilot target. */ - if(pilot_isDisabled(p)) c = &cInert; - else if(pilot_isFlag(p, PILOT_HOSTILE)) 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_targetPilot, x, y, 0, 0, c); /* Top left. */ - - x += p->ship->gfx_space->sw * PILOT_SIZE_APROX; - gl_blitSprite(gui.gfx_targetPilot, x, y, 1, 0, c); /* Top right. */ - - y -= p->ship->gfx_space->sh * PILOT_SIZE_APROX; - gl_blitSprite(gui.gfx_targetPilot, x, y, 1, 1, c); /* Bottom right. */ - - x -= p->ship->gfx_space->sw * PILOT_SIZE_APROX; - gl_blitSprite(gui.gfx_targetPilot, x, y, 0, 1, c); /* Bottom left. */ - } - + /* Lockon warning. */ if(player->lockons > 0) gl_printMid(NULL, SCREEN_W, 0., SCREEN_H-gl_defFont.h-25.,