void BloodSquirt::update() { if(timer.GetElapsedTime() > 0.5f) { for (auto it = parent->gameObjects.begin(); it!=parent->gameObjects.end(); it++) { if (*it == this) { parent->gameObjects.erase(it); break; } } delete this; return; } for (auto it = parent->gameObjects.begin(); it!=parent->gameObjects.end(); it++) { Enemy* obj = dynamic_cast<Enemy*>(*it); if (!obj) continue; if (position.x + 5 < obj->left()) continue; if (position.x - 5 > obj->right()) continue; if (position.y + 5 < obj->top()) continue; if (position.y - 5 > obj->bottom()) continue; for (auto it = parent->gameObjects.begin(); it!=parent->gameObjects.end(); it++) { if (*it == obj) { parent->gameObjects.erase(it); break; } } for (auto it = parent->gameObjects.begin(); it!=parent->gameObjects.end(); it++) { if (*it == this) { parent->gameObjects.erase(it); break; } } parent->gameObjects.push_back(new DeathAnimation(parent, obj->position)); /*for (int i = 0; i < 14; i++) { parent->gameObjects.push_back(new BloodFart(parent, NULL, position, 1, i*24, 2.0f)); parent->gameObjects.push_back(new BloodContact(parent, NULL, Vector2f(obj->position.x+rand()%50-rand()%50, obj->bottom()), rand()%5)); }*/ delete obj; delete this; return; } imageAnimationPos += imageAnimationSpeed * DELTA_TIME; if (imageAnimationPos > imageAnimationSwitch) { imageAnimationPos = 0; if (imageIndex++ >= imageCount-1) imageIndex = 0; } position.x += velocity.x * DELTA_TIME; }