Make bubblegum have much cooler (and nastier) effect
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9719 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
cb47023202
commit
2903c4435e
@ -77,10 +77,11 @@ void SkidMarks::reset()
|
||||
* starts a new skid mark quad.
|
||||
* \param dt Time step.
|
||||
*/
|
||||
void SkidMarks::update(float dt)
|
||||
void SkidMarks::update(float dt, bool force_skid_marks, video::SColor* custom_color)
|
||||
{
|
||||
//if the kart is gnu, then dont skid because he floats!
|
||||
if (m_kart.isWheeless() == false) {
|
||||
if (m_kart.isWheeless() == false)
|
||||
{
|
||||
float f = dt/stk_config->m_skid_fadeout_time*m_start_alpha;
|
||||
for(unsigned int i=0; i<m_left.size(); i++)
|
||||
{
|
||||
@ -106,18 +107,21 @@ void SkidMarks::update(float dt)
|
||||
// delta is 0, and the behaviour is undefined. In this case
|
||||
// just stop doing skid marks as well.
|
||||
// ---------------------------------------------------------
|
||||
if(!raycast_right.m_isInContact || !m_kart.getControls().m_drift ||
|
||||
fabsf(m_kart.getControls().m_steer) < 0.001f ||
|
||||
delta.length2()<0.0001)
|
||||
if (!force_skid_marks)
|
||||
{
|
||||
m_skid_marking = false;
|
||||
// The vertices and indices will not change anymore (till these
|
||||
// skid mark quads are deleted)
|
||||
m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
return;
|
||||
if(!raycast_right.m_isInContact || !m_kart.getControls().m_drift ||
|
||||
fabsf(m_kart.getControls().m_steer) < 0.001f ||
|
||||
delta.length2()<0.0001)
|
||||
{
|
||||
m_skid_marking = false;
|
||||
// The vertices and indices will not change anymore (till these
|
||||
// skid mark quads are deleted)
|
||||
m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We are still skid marking, so add the latest quad
|
||||
// -------------------------------------------------
|
||||
|
||||
@ -139,14 +143,17 @@ void SkidMarks::update(float dt)
|
||||
|
||||
// Currently no skid marking
|
||||
// -------------------------
|
||||
if((!m_kart.getControls().m_drift) ||
|
||||
(fabsf(m_kart.getControls().m_steer) < 0.001f)) return; // no skidmarking
|
||||
|
||||
// not turning enough, don't draw skidmarks if kart is going straight ahead
|
||||
// this is even stricter for Ai karts, since they tend to use LOTS of skidding
|
||||
const float min_skid_angle = m_kart.getController()->isPlayerController() ? 0.55f : 0.95f;
|
||||
if( fabsf(m_kart.getSteerPercent()) < min_skid_angle) return;
|
||||
|
||||
if (!force_skid_marks)
|
||||
{
|
||||
if((!m_kart.getControls().m_drift) ||
|
||||
(fabsf(m_kart.getControls().m_steer) < 0.001f)) return; // not skidmarking
|
||||
|
||||
// not turning enough, don't draw skidmarks if kart is going straight ahead
|
||||
// this is even stricter for Ai karts, since they tend to use LOTS of skidding
|
||||
const float min_skid_angle = m_kart.getController()->isPlayerController() ? 0.55f : 0.95f;
|
||||
if( fabsf(m_kart.getSteerPercent()) < min_skid_angle) return;
|
||||
}
|
||||
|
||||
// Start new skid marks
|
||||
// --------------------
|
||||
const btWheelInfo::RaycastInfo &raycast_right =
|
||||
@ -166,16 +173,17 @@ void SkidMarks::update(float dt)
|
||||
delta *= m_width;
|
||||
|
||||
SkidMarkQuads *smq_left = new SkidMarkQuads(raycast_left.m_contactPointWS,
|
||||
raycast_left.m_contactPointWS + delta,
|
||||
m_material, m_avoid_z_fighting);
|
||||
raycast_left.m_contactPointWS + delta,
|
||||
m_material, m_avoid_z_fighting,
|
||||
custom_color);
|
||||
scene::SMesh *new_mesh = new scene::SMesh();
|
||||
new_mesh->addMeshBuffer(smq_left);
|
||||
|
||||
SkidMarkQuads *smq_right = new SkidMarkQuads(raycast_right.m_contactPointWS
|
||||
- delta,
|
||||
raycast_right.m_contactPointWS,
|
||||
m_material,
|
||||
m_avoid_z_fighting);
|
||||
SkidMarkQuads *smq_right = new SkidMarkQuads(raycast_right.m_contactPointWS - delta,
|
||||
raycast_right.m_contactPointWS,
|
||||
m_material,
|
||||
m_avoid_z_fighting,
|
||||
custom_color);
|
||||
new_mesh->addMeshBuffer(smq_right);
|
||||
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
|
||||
#ifdef DEBUG
|
||||
@ -218,29 +226,40 @@ void SkidMarks::update(float dt)
|
||||
} // update
|
||||
|
||||
//=============================================================================
|
||||
SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left, const Vec3 &right,
|
||||
SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left,
|
||||
const Vec3 &right,
|
||||
video::SMaterial *material,
|
||||
float z_offset)
|
||||
float z_offset,
|
||||
video::SColor* custom_color)
|
||||
: scene::SMeshBuffer()
|
||||
{
|
||||
m_z_offset = z_offset;
|
||||
m_fade_out = 0.0f;
|
||||
|
||||
m_start_color = (custom_color != NULL ? *custom_color :
|
||||
video::SColor(255,
|
||||
SkidMarks::m_start_grey,
|
||||
SkidMarks::m_start_grey,
|
||||
SkidMarks::m_start_grey));
|
||||
|
||||
Material = *material;
|
||||
m_aabb = core::aabbox3df(left.toIrrVector());
|
||||
add(left, right);
|
||||
|
||||
|
||||
} // SkidMarkQuads
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SkidMarks::SkidMarkQuads::add(const Vec3 &left, const Vec3 &right)
|
||||
|
||||
void SkidMarks::SkidMarkQuads::add(const Vec3 &left,
|
||||
const Vec3 &right)
|
||||
{
|
||||
// The skid marks must be raised slightly higher, otherwise it blends
|
||||
// too much with the track.
|
||||
int n = Vertices.size();
|
||||
|
||||
video::S3DVertex v;
|
||||
v.Color = Material.DiffuseColor;
|
||||
v.Color = m_start_color;
|
||||
v.Color.setAlpha(m_start_alpha);
|
||||
v.Pos = left.toIrrVector();
|
||||
v.Pos.Y += m_z_offset;
|
||||
@ -280,14 +299,14 @@ void SkidMarks::SkidMarkQuads::fade(float f)
|
||||
// about 10 times till 0 is reached.
|
||||
if(m_fade_out*10>SkidMarks::m_start_alpha)
|
||||
{
|
||||
video::SColor &c=Material.DiffuseColor;
|
||||
int a=c.getAlpha();
|
||||
a -= a<m_fade_out ? a : (int)m_fade_out;
|
||||
int premul_grey = a * SkidMarks::m_start_grey / 255;
|
||||
c.set(a, premul_grey, premul_grey, premul_grey);
|
||||
video::SColor &c = Material.DiffuseColor;
|
||||
int a = c.getAlpha();
|
||||
a -= (a < m_fade_out ? a : (int)m_fade_out);
|
||||
|
||||
c.setAlpha(a);
|
||||
for(unsigned int i=0; i<Vertices.size(); i++)
|
||||
{
|
||||
Vertices[i].Color.set(a, premul_grey, premul_grey, premul_grey);
|
||||
Vertices[i].Color.setAlpha(a);
|
||||
}
|
||||
m_fade_out = 0.0f;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ private:
|
||||
|
||||
/** Material to use for the skid marks. */
|
||||
video::SMaterial *m_material;
|
||||
|
||||
|
||||
class SkidMarkQuads : public scene::SMeshBuffer, public NoCopy
|
||||
{
|
||||
/** Used to move skid marks at the same location slightly on
|
||||
@ -70,9 +70,13 @@ private:
|
||||
/** For culling, we need the overall radius of the skid marks. We
|
||||
* approximate this by maintaining an axis-aligned boundary box. */
|
||||
core::aabbox3df m_aabb;
|
||||
|
||||
video::SColor m_start_color;
|
||||
|
||||
public:
|
||||
SkidMarkQuads (const Vec3 &left, const Vec3 &right,
|
||||
video::SMaterial *material, float z_offset);
|
||||
video::SMaterial *material, float z_offset,
|
||||
video::SColor* custom_color = NULL);
|
||||
void add (const Vec3 &left,
|
||||
const Vec3 &right);
|
||||
void fade (float f);
|
||||
@ -92,7 +96,7 @@ private:
|
||||
public:
|
||||
SkidMarks(const Kart& kart, float width=0.2f);
|
||||
~SkidMarks();
|
||||
void update (float dt);
|
||||
void update (float dt, bool force_skid_marks=false, video::SColor* custom_color = NULL);
|
||||
void reset();
|
||||
|
||||
void adjustFog(bool enabled);
|
||||
|
@ -158,7 +158,7 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
if (UserConfigParams::m_artist_debug_mode && world)
|
||||
{
|
||||
Kart* kart = world->getLocalPlayerKart(0);
|
||||
kart->setPowerup(PowerupManager::POWERUP_PARACHUTE, 10000);
|
||||
kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000);
|
||||
}
|
||||
break;
|
||||
case KEY_F7:
|
||||
|
@ -95,6 +95,7 @@ Kart::Kart (const std::string& ident, Track* track, int position, bool is_first_
|
||||
m_finished_race = false;
|
||||
m_wheel_toggle = 1;
|
||||
m_finish_time = 0.0f;
|
||||
m_bubblegum_time = 0.0f;
|
||||
m_invulnerable_time = 0.0f;
|
||||
m_squash_time = 0.0f;
|
||||
m_shadow_enabled = false;
|
||||
@ -510,6 +511,7 @@ void Kart::reset()
|
||||
m_race_position = m_initial_position;
|
||||
m_finished_race = false;
|
||||
m_finish_time = 0.0f;
|
||||
m_bubblegum_time = 0.0f;
|
||||
m_invulnerable_time = 0.0f;
|
||||
m_squash_time = 0.0f;
|
||||
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
@ -673,7 +675,9 @@ void Kart::collectedItem(Item *item, int add_info)
|
||||
}
|
||||
case Item::ITEM_BUBBLEGUM:
|
||||
// slow down
|
||||
m_body->setLinearVelocity(m_body->getLinearVelocity()*0.3f);
|
||||
//m_body->setLinearVelocity(m_body->getLinearVelocity()*0.3f);
|
||||
m_bubblegum_time = 1.0f;
|
||||
m_body->setDamping(0.8f, 0.8f);
|
||||
m_goo_sound->position(getXYZ());
|
||||
m_goo_sound->play();
|
||||
// Play appropriate custom character sound
|
||||
@ -765,7 +769,18 @@ void Kart::update(float dt)
|
||||
/*slowdown*/1.0f, /*fade in*/0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (m_bubblegum_time > 0.0f)
|
||||
{
|
||||
m_bubblegum_time -= dt;
|
||||
if (m_bubblegum_time <= 0.0f)
|
||||
{
|
||||
// undo bubblegum effect
|
||||
m_body->setDamping(m_kart_properties->getChassisLinearDamping(),
|
||||
m_kart_properties->getChassisAngularDamping() );
|
||||
}
|
||||
}
|
||||
|
||||
// Update the position and other data taken from the physics
|
||||
Moveable::update(dt);
|
||||
|
||||
@ -935,9 +950,17 @@ void Kart::update(float dt)
|
||||
|
||||
// Check if any item was hit.
|
||||
item_manager->checkItemHit(this);
|
||||
|
||||
static video::SColor pink(255, 255, 133, 253);
|
||||
|
||||
// draw skidmarks if relevant (we force pink skidmarks on when hitting a bubblegum)
|
||||
if(m_kart_properties->hasSkidmarks())
|
||||
m_skidmarks->update(dt);
|
||||
|
||||
{
|
||||
m_skidmarks->update(dt,
|
||||
m_bubblegum_time > 0,
|
||||
(m_bubblegum_time > 0 ? &pink : NULL) );
|
||||
}
|
||||
|
||||
const bool emergency = playingEmergencyAnimation();
|
||||
|
||||
if (emergency)
|
||||
@ -1481,9 +1504,19 @@ void Kart::updatePhysics(float dt)
|
||||
float engine_power = getActualWheelForce() + handleNitro(dt)
|
||||
+ m_slipstream->getSlipstreamPower();
|
||||
|
||||
// apply parachute physics if relevant
|
||||
if(m_attachment->getType()==Attachment::ATTACH_PARACHUTE)
|
||||
engine_power*=0.2f;
|
||||
|
||||
// apply bubblegum physics if relevant
|
||||
if (m_bubblegum_time > 0.0f)
|
||||
{
|
||||
engine_power = 0.0f;
|
||||
m_body->applyTorque(btVector3(0.0, 500.0f, 0.0));
|
||||
m_skidding *= 1.08f; //skid a little when hitting a bubblegum (just enough to make the skiding sound)
|
||||
}
|
||||
|
||||
// apply flying physics if relevant
|
||||
if (m_flying)
|
||||
{
|
||||
if (m_controls.m_accel)
|
||||
@ -1609,7 +1642,8 @@ void Kart::updatePhysics(float dt)
|
||||
|
||||
}
|
||||
#endif
|
||||
if (isOnGround()){
|
||||
if (isOnGround())
|
||||
{
|
||||
if((fabs(m_controls.m_steer) > 0.001f) && m_controls.m_drift)
|
||||
{
|
||||
m_skidding += m_kart_properties->getSkidIncrease()
|
||||
|
@ -123,6 +123,9 @@ private:
|
||||
/** How long a kart is being squashed. If this is >0
|
||||
* the kart is squashed. */
|
||||
float m_squash_time;
|
||||
|
||||
/** If > 0 then bubble gum effect is on */
|
||||
float m_bubblegum_time;
|
||||
|
||||
// Bullet physics parameters
|
||||
// -------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user