J :
* Add a scale factor on the phase bar.
This commit is contained in:
@@ -18,7 +18,7 @@ static int colors[] =
|
|||||||
ARGB(255, 255, 255, 255)
|
ARGB(255, 255, 255, 255)
|
||||||
};
|
};
|
||||||
|
|
||||||
GuiPhaseBar::GuiPhaseBar(GameObserver* game) : GuiLayer(0, game), phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f)
|
GuiPhaseBar::GuiPhaseBar() : phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f)
|
||||||
{
|
{
|
||||||
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/phasebar.png");
|
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/phasebar.png");
|
||||||
if (texture)
|
if (texture)
|
||||||
@@ -42,51 +42,52 @@ void GuiPhaseBar::Update(float dt)
|
|||||||
|
|
||||||
void GuiPhaseBar::Render()
|
void GuiPhaseBar::Render()
|
||||||
{
|
{
|
||||||
static const unsigned CENTER = SCREEN_HEIGHT / 2 - Height / 4;
|
static const float ICONSCALE = 1.5;
|
||||||
|
static const unsigned CENTER = SCREEN_HEIGHT / 2 + 10;
|
||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
unsigned p = (phase->id + Phases - 4) * Width;
|
unsigned p = (phase->id + Phases - 4) * Width;
|
||||||
float scale;
|
float scale;
|
||||||
float start = CENTER + (Width / 2) * angle / (M_PI / 6);
|
float start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4;
|
||||||
|
|
||||||
renderer->DrawLine(0, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT / 2, ARGB(255, 255, 255, 255));
|
renderer->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255));
|
||||||
|
|
||||||
scale = sinf(angle + 3 * M_PI / 6) / 2;
|
scale = ICONSCALE * sinf(angle + 3 * M_PI / 6) / 2;
|
||||||
quad->SetTextureRect((p + 3 * Width) % (Phases * Width), 0, Width, Height);
|
quad->SetTextureRect((p + 3 * Width) % (Phases * Width), 0, Width, Height);
|
||||||
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
||||||
start += Width * scale;
|
start += Width * scale;
|
||||||
|
|
||||||
scale = sinf(angle + 4 * M_PI / 6) / 2;
|
scale = ICONSCALE * sinf(angle + 4 * M_PI / 6) / 2;
|
||||||
quad->SetTextureRect((p + 4 * Width) % (Phases * Width), Height, Width, Height);
|
quad->SetTextureRect((p + 4 * Width) % (Phases * Width), Height, Width, Height);
|
||||||
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
||||||
start += Width * scale;
|
start += Width * scale;
|
||||||
|
|
||||||
scale = sinf(angle + 5 * M_PI / 6) / 2;
|
scale = ICONSCALE * sinf(angle + 5 * M_PI / 6) / 2;
|
||||||
quad->SetTextureRect((p + 5 * Width) % (Phases * Width), Height, Width, Height);
|
quad->SetTextureRect((p + 5 * Width) % (Phases * Width), Height, Width, Height);
|
||||||
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
||||||
start += Width * scale;
|
start += Width * scale;
|
||||||
|
|
||||||
start = CENTER + (Width / 2) * angle / (M_PI / 6);
|
start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4;
|
||||||
|
|
||||||
scale = sinf(angle + 2 * M_PI / 6) / 2;
|
scale = ICONSCALE * sinf(angle + 2 * M_PI / 6) / 2;
|
||||||
start -= Width * scale;
|
start -= Width * scale;
|
||||||
quad->SetTextureRect((p + 2 * Width) % (Phases * Width), Height, Width, Height);
|
quad->SetTextureRect((p + 2 * Width) % (Phases * Width), Height, Width, Height);
|
||||||
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
||||||
|
|
||||||
scale = sinf(angle + 1 * M_PI / 6) / 2;
|
scale = ICONSCALE * sinf(angle + 1 * M_PI / 6) / 2;
|
||||||
start -= Width * scale;
|
start -= Width * scale;
|
||||||
quad->SetTextureRect((p + 1 * Width) % (Phases * Width), Height, Width, Height);
|
quad->SetTextureRect((p + 1 * Width) % (Phases * Width), Height, Width, Height);
|
||||||
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
||||||
|
|
||||||
if (angle > 0)
|
if (angle > 0)
|
||||||
{
|
{
|
||||||
scale = sinf(angle)/2;
|
scale = ICONSCALE * sinf(angle)/2;
|
||||||
start -= Width * scale;
|
start -= Width * scale;
|
||||||
quad->SetTextureRect(p % (Phases * Width), Height, Width, Height);
|
quad->SetTextureRect(p % (Phases * Width), Height, Width, Height);
|
||||||
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GuiPhaseBar::receiveEvent(WEvent *e)
|
int GuiPhaseBar::receiveEventMinus(WEvent *e)
|
||||||
{
|
{
|
||||||
WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e);
|
WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e);
|
||||||
if (event)
|
if (event)
|
||||||
|
|||||||
Reference in New Issue
Block a user