Hello. I'm trying to make dynamic collision detection system. In example: automatically adjust collision detection when new vector of objects added and etc.
Now I have few vectors and I'm trying to do collision by just passing vector/object as parameter in "CheckCollision" function.
player->Update(application, dt);
if (player->CheckCollision(&enemies))
{
InitScene();
application->SetState(GameState::NOTSTARTEDYET);
UI["Pause Menu"]->HideAllElements();
UI["Options"]->HideAllElements();
UI["Main Menu"]->ShowAllElements();
}
for (auto enemy : enemies)
{
enemy->Update(dt, t);
if (enemy->CheckCollision(player))
{
InitScene();
application->SetState(GameState::NOTSTARTEDYET);
UI["Pause Menu"]->HideAllElements();
UI["Options"]->HideAllElements();
UI["Main Menu"]->ShowAllElements();
}
}
Can I somehow change this code to make code more dynamic when I add more vectors with enemies.
↧