More work on overworld UI + give the player infinite nitro
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10620 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "karts/kart.hpp"
|
||||
#include "modes/overworld.hpp"
|
||||
#include "states_screens/race_gui_overworld.hpp"
|
||||
|
||||
@@ -45,6 +46,14 @@ OverWorld::~OverWorld()
|
||||
void OverWorld::update(float dt)
|
||||
{
|
||||
LinearWorld::update(dt);
|
||||
|
||||
const unsigned int kart_amount = m_karts.size();
|
||||
|
||||
// isn't cool, on the overworld nitro is free!
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
{
|
||||
m_karts[n]->setEnergy(100.0f);
|
||||
}
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -189,7 +189,6 @@ void RaceGUIOverworld::renderPlayerView(const Kart *kart)
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
drawPowerupIcons (kart, viewport, scaling);
|
||||
drawSpeedAndEnergy (kart, viewport, scaling);
|
||||
|
||||
RaceGUIBase::renderPlayerView(kart);
|
||||
} // renderPlayerView
|
||||
@@ -376,119 +375,4 @@ void RaceGUIOverworld::drawEnergyMeter(int x, int y, const Kart *kart,
|
||||
} // drawEnergyMeter
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceGUIOverworld::drawSpeedAndEnergy(const Kart* kart, const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
|
||||
float minRatio = std::min(scaling.X, scaling.Y);
|
||||
const int SPEEDWIDTH = 128;
|
||||
int meter_width = (int)(SPEEDWIDTH*minRatio);
|
||||
int meter_height = (int)(SPEEDWIDTH*minRatio);
|
||||
|
||||
drawEnergyMeter(viewport.LowerRightCorner.X,
|
||||
(int)(viewport.LowerRightCorner.Y - meter_height*0.75f),
|
||||
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),
|
||||
(int)(offset.X+meter_width),
|
||||
(int)offset.Y);
|
||||
video::ITexture *meter_texture = m_speed_meter_icon->getTexture();
|
||||
const core::rect<s32> meter_texture_coords(core::position2d<s32>(0,0),
|
||||
meter_texture->getOriginalSize());
|
||||
video->draw2DImage(meter_texture, meter_pos, meter_texture_coords, NULL, NULL, true);
|
||||
|
||||
const float speed = kart->getSpeed();
|
||||
if(speed <=0) return; // Nothing to do if speed is negative.
|
||||
|
||||
// Draw the actual speed bar (if the speed is >0)
|
||||
// ----------------------------------------------
|
||||
float speed_ratio = speed/KILOMETERS_PER_HOUR/110.0f;
|
||||
if(speed_ratio>1) speed_ratio = 1;
|
||||
|
||||
video::ITexture *bar_texture = m_speed_bar_icon->getTexture();
|
||||
core::dimension2du bar_size = bar_texture->getOriginalSize();
|
||||
video::S3DVertex vertices[5];
|
||||
unsigned int count;
|
||||
|
||||
// There are three different polygons used, depending on
|
||||
// the speed ratio. Consider the speed-display texture:
|
||||
//
|
||||
// C----x----D (position of v,w,x,y vary depending on
|
||||
// | | speed)
|
||||
// w y
|
||||
// | |
|
||||
// B----A----E
|
||||
// For speed ratio <= r1 the triangle ABw is used, with w between B and C.
|
||||
// For speed ratio <= r2 the quad ABCx is used, with x between C and D.
|
||||
// For speed ratio > r2 the poly ABCDy is used, with y between D and E.
|
||||
|
||||
vertices[0].TCoords = core::vector2df(0.5f, 1.0f);
|
||||
vertices[0].Pos = core::vector3df(offset.X+meter_width/2, offset.Y, 0);
|
||||
vertices[1].TCoords = core::vector2df(0, 1.0f);
|
||||
vertices[1].Pos = core::vector3df(offset.X, offset.Y, 0);
|
||||
// The speed ratios at which different triangles must be used.
|
||||
// These values should be adjusted in case that the speed display
|
||||
// is not linear enough. Mostly the speed values are below 0.7, it
|
||||
// needs some zipper to get closer to 1.
|
||||
const float r1 = 0.4f;
|
||||
const float r2 = 0.8f;
|
||||
if(speed_ratio<=r1)
|
||||
{
|
||||
count = 3;
|
||||
float f = speed_ratio/r1;
|
||||
vertices[2].TCoords = core::vector2df(0, 1.0f-f);
|
||||
vertices[2].Pos = core::vector3df(offset.X, offset.Y-f*meter_height,0);
|
||||
}
|
||||
else if(speed_ratio<=r2)
|
||||
{
|
||||
count = 4;
|
||||
float f = (speed_ratio - r1)/(r2-r1);
|
||||
vertices[2].TCoords = core::vector2df(0,0);
|
||||
vertices[2].Pos = core::vector3df(offset.X, offset.Y-meter_height, 0);
|
||||
vertices[3].TCoords = core::vector2df(f, 0);
|
||||
vertices[3].Pos = core::vector3df(offset.X+f*meter_width,
|
||||
offset.Y-meter_height,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 5;
|
||||
float f = (speed_ratio - r2)/(1-r2);
|
||||
vertices[2].TCoords = core::vector2df(0,0);
|
||||
vertices[2].Pos = core::vector3df(offset.X, offset.Y-meter_height, 0);
|
||||
vertices[3].TCoords = core::vector2df(1, 0);
|
||||
vertices[3].Pos = core::vector3df(offset.X+meter_width,
|
||||
offset.Y-meter_height,
|
||||
0);
|
||||
vertices[4].TCoords = core::vector2df(1.0f, f);
|
||||
vertices[4].Pos = core::vector3df(offset.X+meter_width,
|
||||
offset.Y - (1-f)*meter_height,
|
||||
0);
|
||||
}
|
||||
short int index[5];
|
||||
for(unsigned int i=0; i<count; i++)
|
||||
{
|
||||
index[i]=i;
|
||||
vertices[i].Color = video::SColor(255, 255, 255, 255);
|
||||
}
|
||||
video::SMaterial m;
|
||||
m.setTexture(0, m_speed_bar_icon->getTexture());
|
||||
m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
irr_driver->getVideoDriver()->setMaterial(m);
|
||||
irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, count,
|
||||
index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN);
|
||||
*/
|
||||
} // drawSpeed
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -91,8 +91,6 @@ private:
|
||||
void drawEnergyMeter (int x, int y, const Kart *kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawSpeedAndEnergy (const Kart* kart, const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
|
||||
/** Display items that are shown once only (for all karts). */
|
||||
void drawGlobalMiniMap ();
|
||||
|
||||
Reference in New Issue
Block a user