'Animated' the plunger-in-face somewhat, and additionally reduced
plunger-in-face time somewhat. Atm you can test by pressing F1 in a race (which I'll remove soonish). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11761 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
09e9768df0
commit
ddea03ebe5
@ -449,7 +449,7 @@
|
||||
in your face is removed. -->
|
||||
<plunger band-max-length="50" band-force="1500" band-duration="1"
|
||||
band-speed-increase="7" band-fade-out-time="3"
|
||||
in-face-time="4 6 7"/>
|
||||
in-face-time="3 4 4.5"/>
|
||||
|
||||
<!-- Kart-specific explosion parameters.
|
||||
Time: how long it takes before the kart can drive again (this
|
||||
|
@ -174,6 +174,8 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
// a rescue loop: rescue, drive, crash, rescue to same place
|
||||
world->getKart(0)->forceRescue();
|
||||
#endif
|
||||
// FIXME: remove after testing the animated plunger
|
||||
world->getLocalPlayerKart(0)->blockViewWithPlunger();
|
||||
}
|
||||
break;
|
||||
case KEY_F2:
|
||||
|
@ -198,7 +198,7 @@ public:
|
||||
virtual float getFinishTime() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the kart has a plunger attached to its face. */
|
||||
virtual bool hasViewBlockedByPlunger() const = 0;
|
||||
virtual float getBlockedByPlungerTime() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets that the view is blocked by a plunger. The duration depends on
|
||||
* the difficulty, see KartPorperties getPlungerInFaceTime. */
|
||||
|
@ -275,7 +275,7 @@ float AIBaseController::steerToAngle(const unsigned int sector,
|
||||
//Desired angle minus current angle equals how many angles to turn
|
||||
float steer_angle = angle - m_kart->getHeading();
|
||||
|
||||
if(m_kart->hasViewBlockedByPlunger())
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
steer_angle += add_angle*0.2f;
|
||||
else
|
||||
steer_angle += add_angle;
|
||||
@ -406,7 +406,7 @@ void AIBaseController::setSteering(float angle, float dt)
|
||||
if (steer_fraction > 1.0f) steer_fraction = 1.0f;
|
||||
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
|
||||
|
||||
if(m_kart->hasViewBlockedByPlunger())
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
{
|
||||
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
|
||||
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;
|
||||
@ -437,7 +437,7 @@ void AIBaseController::setSteering(float angle, float dt)
|
||||
bool AIBaseController::doSkid(float steer_fraction)
|
||||
{
|
||||
// Disable skidding when a plunger is in the face
|
||||
if(m_kart->hasViewBlockedByPlunger()) return false;
|
||||
if(m_kart->getBlockedByPlungerTime()>0) return false;
|
||||
|
||||
// FIXME: Disable skidding for now if the new skidding
|
||||
// code is activated, since the AI can not handle this
|
||||
|
@ -1356,7 +1356,7 @@ void SkiddingAI::handleAcceleration( const float dt)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_kart->hasViewBlockedByPlunger())
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
{
|
||||
if(m_kart->getSpeed() < m_kart->getCurrentMaxSpeed() / 2)
|
||||
m_controls->m_accel = 0.05f;
|
||||
@ -1424,7 +1424,7 @@ void SkiddingAI::handleNitroAndZipper()
|
||||
if(m_kart->getSpeed() > 0.95f*m_kart->getCurrentMaxSpeed())
|
||||
return;
|
||||
// Don't use nitro when the AI has a plunger in the face!
|
||||
if(m_kart->hasViewBlockedByPlunger()) return;
|
||||
if(m_kart->getBlockedByPlungerTime()>0) return;
|
||||
|
||||
// Don't use nitro if we are braking
|
||||
if(m_controls->m_brake) return;
|
||||
@ -2210,7 +2210,7 @@ void SkiddingAI::setSteering(float angle, float dt)
|
||||
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
|
||||
|
||||
// Restrict steering when a plunger is in the face
|
||||
if(m_kart->hasViewBlockedByPlunger())
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
{
|
||||
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
|
||||
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;
|
||||
|
@ -321,7 +321,6 @@ void Kart::reset()
|
||||
m_saved_controller = NULL;
|
||||
}
|
||||
m_kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
m_view_blocked_by_plunger = 0.0;
|
||||
m_attachment->clear();
|
||||
m_kart_gfx->reset();
|
||||
m_skidding->reset();
|
||||
|
@ -315,14 +315,18 @@ public:
|
||||
virtual bool hasFinishedRace () const { return m_finished_race; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the kart has a plunger attached to its face. */
|
||||
virtual bool hasViewBlockedByPlunger() const
|
||||
{ return m_view_blocked_by_plunger > 0; }
|
||||
virtual float getBlockedByPlungerTime() const
|
||||
{ return m_view_blocked_by_plunger; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets that the view is blocked by a plunger. The duration depends on
|
||||
* the difficulty, see KartPorperties getPlungerInFaceTime. */
|
||||
virtual void blockViewWithPlunger()
|
||||
{ m_view_blocked_by_plunger =
|
||||
m_kart_properties->getPlungerInFaceTime();}
|
||||
{
|
||||
// Avoid that a plunger extends the plunger time
|
||||
if(m_view_blocked_by_plunger<=0)
|
||||
m_view_blocked_by_plunger =
|
||||
m_kart_properties->getPlungerInFaceTime();
|
||||
} // blockViewWithPlunger
|
||||
// -------------------------------------------------------------------------
|
||||
/** Returns a bullet transform object located at the kart's position
|
||||
and oriented in the direction the kart is going. Can be useful
|
||||
|
@ -205,36 +205,10 @@ void MinimalRaceGUI::renderPlayerView(const AbstractKart *kart)
|
||||
|
||||
const core::recti &viewport = kart->getCamera()->getViewport();
|
||||
core::vector2df scaling = kart->getCamera()->getScaling();
|
||||
//std::cout << "Applied ratio : " << viewport.getWidth()/800.0f << std::endl;
|
||||
|
||||
scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size
|
||||
|
||||
//std::cout << "Scale : " << scaling.X << ", " << scaling.Y << std::endl;
|
||||
|
||||
if (kart->hasViewBlockedByPlunger())
|
||||
{
|
||||
int offset_y = viewport.UpperLeftCorner.Y;
|
||||
|
||||
const int screen_width = viewport.LowerRightCorner.X
|
||||
- viewport.UpperLeftCorner.X;
|
||||
const int plunger_size = viewport.LowerRightCorner.Y
|
||||
- viewport.UpperLeftCorner.Y;
|
||||
int plunger_x = viewport.UpperLeftCorner.X + screen_width/2
|
||||
- plunger_size/2;
|
||||
|
||||
video::ITexture *t=m_plunger_face->getTexture();
|
||||
core::rect<s32> dest(plunger_x, offset_y,
|
||||
plunger_x+plunger_size, offset_y+plunger_size);
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0),
|
||||
t->getOriginalSize());
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(t, dest, source,
|
||||
NULL /* clip */,
|
||||
NULL /* color */,
|
||||
true /* alpha */);
|
||||
}
|
||||
|
||||
|
||||
drawPlungerInFace(kart);
|
||||
drawAllMessages (kart, viewport, scaling);
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
|
@ -190,38 +190,10 @@ void RaceGUI::renderPlayerView(const AbstractKart *kart)
|
||||
const core::recti &viewport = kart->getCamera()->getViewport();
|
||||
|
||||
core::vector2df scaling = kart->getCamera()->getScaling();
|
||||
//std::cout << "Applied ratio : " << viewport.getWidth()/800.0f << std::endl;
|
||||
|
||||
drawPlungerInFace(kart);
|
||||
|
||||
scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size
|
||||
|
||||
//std::cout << "Scale : " << scaling.X << ", " << scaling.Y << std::endl;
|
||||
|
||||
if (kart->hasViewBlockedByPlunger())
|
||||
{
|
||||
const int screen_width = viewport.LowerRightCorner.X
|
||||
- viewport.UpperLeftCorner.X;
|
||||
const int plunger_size = (int)(0.6f * screen_width);
|
||||
int plunger_x = viewport.UpperLeftCorner.X + screen_width/2
|
||||
- plunger_size/2;
|
||||
|
||||
int offset_y = viewport.UpperLeftCorner.Y + viewport.getHeight()/2 - plunger_size/2;
|
||||
|
||||
video::ITexture *t=m_plunger_face->getTexture();
|
||||
core::rect<s32> dest(plunger_x, offset_y,
|
||||
plunger_x+plunger_size, offset_y+plunger_size);
|
||||
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0),
|
||||
t->getOriginalSize());
|
||||
|
||||
//static const video::SColor white = video::SColor(255, 255, 255, 255);
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(t, dest, source,
|
||||
&viewport /* clip */,
|
||||
NULL /* color */,
|
||||
true /* alpha */);
|
||||
}
|
||||
|
||||
|
||||
drawAllMessages (kart, viewport, scaling);
|
||||
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
@ -980,7 +980,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(const KartIconDisplayInfo* info,
|
||||
}
|
||||
|
||||
//Plunger
|
||||
if (kart->hasViewBlockedByPlunger())
|
||||
if (kart->getBlockedByPlungerTime()>0)
|
||||
{
|
||||
video::ITexture *icon_plunger =
|
||||
powerup_manager->getIcon(PowerupManager::POWERUP_PLUNGER)->getTexture();
|
||||
@ -1013,3 +1013,45 @@ void RaceGUIBase::drawGlobalPlayerIcons(const KartIconDisplayInfo* info,
|
||||
|
||||
} //next position
|
||||
} // drawGlobalPlayerIcons
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Draws the plunger-in-face if necessary. Does nothing if there is no
|
||||
* plunger in face atm.
|
||||
*/
|
||||
void RaceGUIBase::drawPlungerInFace(const AbstractKart *kart)
|
||||
{
|
||||
if (kart->getBlockedByPlungerTime()<=0) return;
|
||||
|
||||
const core::recti &viewport = kart->getCamera()->getViewport();
|
||||
|
||||
const int screen_width = viewport.LowerRightCorner.X
|
||||
- viewport.UpperLeftCorner.X;
|
||||
const int plunger_size = (int)(0.6f * screen_width);
|
||||
int plunger_x = viewport.UpperLeftCorner.X + screen_width/2
|
||||
- plunger_size/2;
|
||||
int plunger_offset = 0;
|
||||
if(kart->getBlockedByPlungerTime()<3)
|
||||
{
|
||||
int height = viewport.LowerRightCorner.Y
|
||||
- viewport.UpperLeftCorner.Y;
|
||||
const float anim_time=3.0f;
|
||||
// Map remaining plunger time between [anim_time,0] time to [0,1]
|
||||
float f = (anim_time - kart->getBlockedByPlungerTime())/anim_time;
|
||||
plunger_offset = (int)(f*height*0.5f);
|
||||
}
|
||||
|
||||
int offset_y = viewport.UpperLeftCorner.Y + viewport.getHeight()/2
|
||||
- plunger_size/2 - plunger_offset;
|
||||
|
||||
video::ITexture *t=m_plunger_face->getTexture();
|
||||
core::rect<s32> dest(plunger_x, offset_y,
|
||||
plunger_x+plunger_size, offset_y+plunger_size);
|
||||
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0),
|
||||
t->getOriginalSize());
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(t, dest, source,
|
||||
&viewport /* clip */,
|
||||
NULL /* color */,
|
||||
true /* alpha */ );
|
||||
} // drawPlungerInFace
|
@ -176,7 +176,7 @@ protected:
|
||||
const core::vector2df &scaling);
|
||||
void drawGlobalMusicDescription();
|
||||
void drawGlobalReadySetGo ();
|
||||
|
||||
void drawPlungerInFace(const AbstractKart *kart);
|
||||
/** Instructs the base gui to ignore unimportant messages (like
|
||||
* item messages).
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user