Код: Выделить всё
target.Update();
if (target.GetEnergy() > 0.0f) {Collisions::IsTargetHit(target);}
< /code>
Я оставлю целевое обновление, пока не покажу Istargethit < /p>
bool Collisions::IsTargetHit(Target& target) {
// get a pointer to all hero's proton-bullets
std::vector* p_bullets = HeroShoot::GetBurst();
// check collision with target for every proton-bullet
for (const auto& bullet : *p_bullets) {
if (CheckCollisionRecs(bullet->GetProtonBounds(),target.GetTargetBounds())) {
// receive damage from bullet and reduce it from target
target.TakeDamage(bullet->GetPower());
bullet->SetHit(true);
return true;
}
}
return false;
}
< /code>
Если нажмите, обновляет энергию. Если энергия изменяется до отрицательного, то она устанавливает сжигание флага _ Код: Выделить всё
float Target::TakeDamage(const float damage) {
if (energy_ > 0.0) {
energy_ -= damage;
if (energy_
А теперь целевое обновление: < /p>
void Target::Update() {
if (burning_) {
burning_ = target_blast_->UpdateBlast();
}
RestoreTarget();
}
< /code>
, который вызывает обновление взрыва, где я думаю, что моя логика не удается < /p>
bool Explosion::UpdateBlast() {
if (frame_ >= max_frames_) {
frame_ = 0;
return false;
}
const float dt = GetFrameTime();
if (accumulated_time_ >= explosion_frame_rate_) {
frame_++;
accumulated_time_ = 0.f;
}
else {
accumulated_time_ += dt;
}
return true;
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... -explosion
Мобильная версия