"skid0" effect

This commit is contained in:
Qwerty Chouskie 2018-05-02 22:23:16 -07:00
parent ded672ea0d
commit 173702cca1
4 changed files with 60 additions and 10 deletions

29
data/gfx/skid0.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<particles emitter="sphere" radius="0.03">
<spreading angle="25" />
<velocity x="0.0"
y="0.008"
z="-0.015" />
<material file="skid-particle1.png" />
<!-- Amount of particles emitted per second. The minimum rate
is used to show that the skidding bonus is now available,
the maximum is used when the skid bonus is applied to the kart -->
<rate min="200"
max="200" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="60"
max="70" />
<!-- Size of the particles -->
<size min="0.20"
max="0.20" />
<color min="255 255 255"
max="255 255 255" />
</particles>

View File

@ -117,6 +117,8 @@ KartGFX::KartGFX(const AbstractKart *kart, bool is_day)
addEffect(KGFX_SKID1R, "skid1.xml", rear_right, true );
addEffect(KGFX_SKID2L, "skid2.xml", rear_left, true );
addEffect(KGFX_SKID2R, "skid2.xml", rear_right, true );
addEffect(KGFX_SKID0L, "skid0.xml", rear_left, true );
addEffect(KGFX_SKID0R, "skid0.xml", rear_right, true );
if (!kart->getKartModel()->getExhaustXML().empty())
{
const std::string& ex = kart->getKartModel()->getExhaustXML();
@ -180,9 +182,9 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
kind = ParticleKindManager::get()->getParticles(file_name);
//kind = new ParticleKind(file_manager->getGfxFile(file_name));
// Skid2 is only used to store the emitter type, and a wheeless
// kart has no terrain effects.
if(type==KGFX_SKID2L || type==KGFX_SKID2R ||
// Skid0 and Skid2 are only used to store the emitter type, and a
// wheeless kart has no terrain effects.
if(type==KGFX_SKID0L || type==KGFX_SKID0R || type==KGFX_SKID2L || type==KGFX_SKID2R ||
(type==KGFX_TERRAIN && m_kart->isWheeless()) )
emitter = NULL;
else if(type==KGFX_TERRAIN)
@ -206,7 +208,9 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
}
assert((int)m_all_emitters.size()==type);
m_all_emitters.push_back(emitter);
if(type==KGFX_SKID1L || type==KGFX_SKID1R)
if (type==KGFX_SKID0L || type==KGFX_SKID0R)
m_skid_kind0 = kind;
else if(type==KGFX_SKID1L || type==KGFX_SKID1R)
m_skid_kind1 = kind;
else if (type==KGFX_SKID2L || type==KGFX_SKID2R)
m_skid_kind2 = kind;
@ -234,15 +238,23 @@ void KartGFX::reset()
// ----------------------------------------------------------------------------
/** Selects the correct skidding particle type depending on skid bonus level.
* \param level Must be 1 (accumulated enough for level 1 bonus) or 2
* (accumulated enough for level 2 bonus).
* \param level Must be 0 (no bonus, showing tiny sparks), 1 (accumulated enough
* for level 1 bonus), or 2 (accumulated enough for level 2 bonus).
*/
void KartGFX::setSkidLevel(const unsigned int level)
{
assert(level >= 1);
assert(level >= 0);
assert(level <= 2);
m_skid_level = level;
const ParticleKind *pk = level==1 ? m_skid_kind1 : m_skid_kind2;
const ParticleKind *pk;
if (level == 0) {
pk = m_skid_kind0;
} else if (level == 1) {
pk = m_skid_kind1;
} else {
pk = m_skid_kind2;
}
// const ParticleKind *pk = level==1 ? m_skid_kind1 : m_skid_kind2;
#ifndef SERVER_ONLY
if(m_all_emitters[KGFX_SKID1L])
m_all_emitters[KGFX_SKID1L]->setParticleType(pk);

View File

@ -40,7 +40,7 @@ class KartGFX
{
public:
/** All particle effects supported by this object.
* Nitro, zipper, terrain, and skidding effects. Two different
* Nitro, zipper, terrain, and skidding effects. Three different
* skid types are supported, but only one emitter node will be
* created. So KGFX_SKID1/2 store the two types, and KGFX_SKID
* = KGFX_SKID1 stores the actual emitter node. KGFX_COUNT
@ -57,11 +57,16 @@ public:
KGFX_SKID1R = KGFX_SKIDR,
KGFX_SKID2L,
KGFX_SKID2R,
KGFX_SKID0L,
KGFX_SKID0R,
KGFX_EXHAUST1,
KGFX_EXHAUST2,
KGFX_COUNT};
private:
/** The particle kind for skidding bonus level 0. */
const ParticleKind *m_skid_kind0;
/** The particle kind for skidding bonus level 1. */
const ParticleKind *m_skid_kind1;

View File

@ -429,8 +429,12 @@ void Skidding::update(int ticks, bool is_on_ground,
float bonus_time, bonus_speed, bonus_force;
unsigned int level = getSkidBonus(&bonus_time, &bonus_speed,
&bonus_force);
// Show tiny sparks if bonus not yet reached
if (level == 0 && m_remaining_jump_time <= 0.0f)
m_kart->getKartGFX()->setSkidLevel(level);
// If at least level 1 bonus is reached, show appropriate gfx
if(level>0)
else if (level>=1)
{
m_skid_bonus_ready = true;
m_kart->getKartGFX()->setSkidLevel(level);