Say hello to the new nitro bar, thanks to Dakal (it only goes up to 16, while old one went up to 20, but I don't think it matters, I never reached 20 in real gameplay anyway)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7351 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-01-10 20:08:41 +00:00
parent a9d7500fe2
commit 79b41ace2a
9 changed files with 60 additions and 64 deletions

View File

@ -16,6 +16,8 @@ title_font, by Marianne Gagnon (Auria), released under CC-BY-SA 3+
screen*.png, by Marianne Gagnon (Auria), including elements from the public domain Tango icon set
Gauge by Dakal, release under CC-BY-SA 3
====
Glass Skin by Auria, under CC-BY-SA 3+

BIN
data/gui/gauge_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
data/gui/gauge_full.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
data/gui/gauge_goal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -392,8 +392,8 @@ void PlayerController::handleZipper(bool play_sound)
*/
void PlayerController::collectedItem(const Item &item, int add_info, float old_energy)
{
if(old_energy < MAX_ITEMS_COLLECTED &&
m_kart->getEnergy() == MAX_ITEMS_COLLECTED)
if(old_energy < MAX_NITRO &&
m_kart->getEnergy() == MAX_NITRO)
{
m_full_sound->play();
}

View File

@ -604,8 +604,8 @@ void Kart::collectedItem(Item *item, int add_info)
race_state->itemCollected(getWorldKartId(), item->getItemId());
}
if ( m_collected_energy > MAX_ITEMS_COLLECTED )
m_collected_energy = MAX_ITEMS_COLLECTED;
if ( m_collected_energy > MAX_NITRO )
m_collected_energy = MAX_NITRO;
m_controller->collectedItem(*item, add_info, old_energy);
} // collectedItem

View File

@ -32,10 +32,7 @@ using namespace irr;
class Material;
/* Limits of Kart performance */
#define CRASH_PITCH -45.0f
#define MAX_ITEMS_COLLECTED 20
const int MAX_NITRO = 16;
/**
* \ingroup karts

View File

@ -85,6 +85,10 @@ RaceGUI::RaceGUI()
m_plunger_face = material_manager->getMaterial("plungerface.png");
m_music_icon = material_manager->getMaterial("notes.png");
createMarkerTexture();
m_gauge_full = irr_driver->getTexture( file_manager->getGUIDir() + "gauge_full.png" );
m_gauge_empty = irr_driver->getTexture( file_manager->getGUIDir() + "gauge_empty.png" );
m_gauge_goal = irr_driver->getTexture( file_manager->getGUIDir() + "gauge_goal.png" );
// Translate strings only one in constructor to avoid calling
// gettext in each frame.
@ -736,64 +740,52 @@ void RaceGUI::drawEnergyMeter(int x, int y, const Kart *kart,
const core::recti &viewport,
const core::vector2df &scaling)
{
float state = (float)(kart->getEnergy()) / MAX_ITEMS_COLLECTED;
// Don't scale width, it looks too small otherwise
int w = 16;
float state = (float)(kart->getEnergy()) / MAX_NITRO;
if (state < 0.0f) state = 0.0f;
else if (state > 1.0f) state = 1.0f;
int h = (int)(viewport.getHeight()/3);
// Move energy bar slighty 'into' the speedometer. Leave 10 points
// between right edge of viewport and energy meter, and don't scale.
x -= w+10;
y -= (int)(30*scaling.Y);
int w = h/4; // gauge image is so 1:4
float coin_target = (float)race_manager->getCoinTarget();
int th = (int)(h*(coin_target/MAX_ITEMS_COLLECTED));
x -= w;
video::SColor black_border(255, 0, 0, 0);
video::SColor white_border(255, 255, 255, 255);
video::IVideoDriver *video = irr_driver->getVideoDriver();
#define LINE(x0,y0,x1,y1, color) video->draw2DLine(core::position2di(x0,y0), \
core::position2di(x1,y1), color)
// Left side:
LINE(x-1, y+1, x-1, y-h-1, black_border);
LINE(x, y, x, y-h-2, white_border);
// Right side:
LINE(x+w, y+1, x+w, y-h-1, black_border);
LINE(x+w+1, y, x+w+1, y-h-2, white_border);
// Bottom
LINE(x, y+1, x+w, y+1, black_border);
LINE(x+1, y, x+w+1, y, white_border);
// Top
LINE(x, y-h, x+w, y-h, black_border);
LINE(x, y-h-1, x+w, y-h-1, white_border);
const int GRADS = (int)(MAX_ITEMS_COLLECTED/5); // each graduation equals 5 items
int gh = (int)(h/GRADS); //graduation height
// 'Meter marks;
int gh_incr = gh;
for (int i=0; i<GRADS-1; i++)
// Background
irr_driver->getVideoDriver()->draw2DImage(m_gauge_empty, core::rect<s32>(x, y, x+w, y+h) /* dest rect */,
core::rect<s32>(0, 0, 64, 256) /* source rect */,
NULL /* clip rect */, NULL /* colors */,
true /* alpha */);
// Target
if (race_manager->getCoinTarget() > 0)
{
LINE(x+1, y-1-gh, x+1+w, y-1-gh, white_border);
gh+=gh_incr;
float coin_target = (float)race_manager->getCoinTarget() / MAX_NITRO;
const int EMPTY_TOP_PIXELS = 4;
const int EMPTY_BOTTOM_PIXELS = 3;
int y1 = y + EMPTY_TOP_PIXELS + (h - EMPTY_TOP_PIXELS - EMPTY_BOTTOM_PIXELS)*(1.0f - coin_target);
if (state >= 1.0f) y1 = y;
core::rect<s32> clip(x, y1, x + w, y + h);
irr_driver->getVideoDriver()->draw2DImage(m_gauge_goal, core::rect<s32>(x, y, x+w, y+h) /* dest rect */,
core::rect<s32>(0, 0, 64, 256) /* source rect */,
&clip, NULL /* colors */, true /* alpha */);
}
//Target line
if (coin_target > 0)
// Filling (current state)
if (state > 0.0f)
{
LINE(x+1, y-1-th, x+1+w, y-1-th, video::SColor(255, 255, 0, 0));
const int EMPTY_TOP_PIXELS = 4;
const int EMPTY_BOTTOM_PIXELS = 3;
int y1 = y + EMPTY_TOP_PIXELS + (h - EMPTY_TOP_PIXELS - EMPTY_BOTTOM_PIXELS)*(1.0f - state);
if (state >= 1.0f) y1 = y;
core::rect<s32> clip(x, y1, x + w, y + h);
irr_driver->getVideoDriver()->draw2DImage(m_gauge_full, core::rect<s32>(x, y, x+w, y+h) /* dest rect */,
core::rect<s32>(0, 0, 64, 256) /* source rect */,
&clip, NULL /* colors */, true /* alpha */);
}
#undef LINE
// The actual energy meter
core::rect<s32> energy(x+1, y-1-(int)(state*h), x+1+w, y-1);
video::SColor bottom(255, 240, 0, 0);
video::SColor top (160, 240, 200, 0);
video->draw2DRectangle(energy, top, top, bottom, bottom);
} // drawEnergyMeter
//-----------------------------------------------------------------------------
@ -805,17 +797,18 @@ void RaceGUI::drawSpeedAndEnergy(const Kart* kart, const core::recti &viewport,
const int SPEEDWIDTH = 128;
int meter_width = (int)(SPEEDWIDTH*minRatio);
int meter_height = (int)(SPEEDWIDTH*minRatio);
core::vector2df offset;
offset.X = (float)(viewport.LowerRightCorner.X-meter_width) - 15.0f*scaling.X;
offset.Y = viewport.LowerRightCorner.Y-10*scaling.Y;
drawEnergyMeter(viewport.LowerRightCorner.X,
viewport.LowerRightCorner.Y - meter_height, kart,
viewport.LowerRightCorner.Y - meter_height*2, kart,
viewport, scaling);
// First draw the meter (i.e. the background which contains the numbers etc.
// -------------------------------------------------------------------------
core::vector2df offset;
offset.X = (float)(viewport.LowerRightCorner.X-meter_width) - 15.0f*scaling.X;
offset.Y = viewport.LowerRightCorner.Y-10*scaling.Y;
video::IVideoDriver *video = irr_driver->getVideoDriver();
const core::rect<s32> meter_pos((int)offset.X,
(int)(offset.Y-meter_height),

View File

@ -100,6 +100,10 @@ private:
/** Translated strings 'ready', 'set', 'go'. */
core::stringw m_string_ready, m_string_set, m_string_go;
video::ITexture *m_gauge_empty;
video::ITexture *m_gauge_full;
video::ITexture *m_gauge_goal;
// Minimap related variables
// -------------------------
/** The mini map of the track. */