void DiscoGrenade::Refresh() { WeaponProjectile::Refresh(); #ifdef HAVE_A_REALLY_BIG_CPU if(IsMoving()) { Double norme,angle; GetSpeed(norme,angle); for (int i = -3; i<4 ; i++) smoke_engine.AddNow(GetPosition(), 1, particle_MAGIC_STAR, false, angle+(i*QUARTER_PI/3.0)+HALF_PI, 2.0); } else { smoke_engine.AddNow(GetPosition(), 1, particle_MAGIC_STAR, false, ((Double)(GameTime::GetInstance()->Read()%500)-250.0) * PI / 250.0, 3.0); } #else // :-P smoke_engine.AddPeriodic(GetPosition(), particle_MAGIC_STAR, false); #endif //HAVE_A_REALLY_BIG_CPU int tmp_time = GetMSSinceTimeoutStart(); // Ah ! Ah ! Ah ! Staying Alive, staying alive ... if (GetTotalTimeout() >= 2 && tmp_time > (1000 * GetTotalTimeout() - 2000) && !have_played_music) { //JukeBox::GetInstance()->Play("default","weapon/alleluia") ; have_played_music = true; } image->SetRotation_rad(GetSpeedAngle()); }
void CluzookaRocket::Refresh() { WeaponProjectile::Refresh(); if (!IsDrowned()) { //image->SetRotation_rad(GetSpeedAngle()); Double flying_time = ( Double )(GetMSSinceTimeoutStart()); Double speed_angle = GetSpeedAngle(); const Double time_to_rotate = 500; const Double num_of_full_rotates = 4; // make it rotate itself for first N msec if (flying_time < time_to_rotate) { Double t = flying_time / time_to_rotate; // portion of time Double inv_t = ONE - t; // rotate speed is max when t is close to 0, and slows down to 1 // when t is approaching 1 //Double rotate_speed = 1 + num_of_full_rotates * ( 1.0f - t ); inv_t *= inv_t; image->SetRotation_rad(speed_angle + TWO_PI * num_of_full_rotates * inv_t * inv_t); } else { image->SetRotation_rad(speed_angle); } smoke_engine.AddPeriodic(Point2i(GetX() + GetWidth() / 2, GetY() + GetHeight()/ 2), particle_DARK_SMOKE, false, -1, 2.0); } else { image->SetRotation_rad(HALF_PI); } }
void Cluster::Refresh() { WeaponProjectile::Refresh(); // make it rotate Double flying_time = (Double) GetMSSinceTimeoutStart(); const Double rotations_per_second = 4; image->SetRotation_rad( rotations_per_second * TWO * PI * flying_time / (Double)1000 ); }
void FootBomb::Refresh() { WeaponProjectile::Refresh(); // image->SetRotation_rad(GetSpeedAngle()); if (IsMoving()) { #define ROTATIONS_PER_SECOND 4 image->SetRotation_rad((ROTATIONS_PER_SECOND*GetMSSinceTimeoutStart()*2) * PI / 1000 ); } }
void Polecat::Refresh() { if (m_energy == 0) { Explosion(); return; } int tmp = GetMSSinceTimeoutStart(); if (cfg.timeout && tmp > 1000 * (GetTotalTimeout())) { if (!last_fart_time) { std::string txt = Format(_("%s has done something for the environment, he has not ordered the polecat to fart."), ActiveCharacter().GetName().c_str()); Weapon::Message(txt); } SignalTimeout(); } Double norm, angle; if (last_fart_time && last_fart_time + TIME_BETWEEN_FART < GameTime::GetInstance()->Read()) { Fart(); } //When we hit the ground, jump ! if(!IsMoving() && !FootsInVacuum()) { // Limiting number of rebound to avoid desync if(last_rebound_time + TIME_BETWEEN_REBOUND > GameTime::GetInstance()->Read()) { image->SetRotation_rad(0.0); return; } last_rebound_time = GameTime::GetInstance()->Read(); MSG_DEBUG("weapon.polecat", "Jump ! (time = %d)", last_rebound_time); //If the GNU is stuck in ground -> change direction int x = GetX(); int y = GetY(); if(x == save_x && y == save_y) m_sens = -m_sens; save_x = x; save_y = y; //Do the jump norm = RandomSync().GetDouble(1.0, 2.0); PutOutOfGround(); SetSpeedXY(Point2d(m_sens * norm , -norm * THREE)); } //Due to a bug in the physic engine //sometimes, angle==infinite (according to gdb) ?? GetSpeed(norm, angle); angle = RestrictAngle(angle) * ONE_HALF; bool flipped = m_sens == -1; if (flipped) { if (angle > 0) angle -= HALF_PI; else angle += HALF_PI; } image->SetRotation_rad(angle); image->SetFlipped(flipped); image->Scale(ONE, ONE); image->Update(); }