Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Need help with what pattern to use for collision detection

$
0
0
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.

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>