How do I do collision detection between the player and an obstacle / pickup?
There
are many techniques for collision detection.
In this module, my advice is to keep
it simple. The
simplest form of collision detection:
glm::length()
If
the distance between two objects is below a threshold T, register a collision.
if (glm::length(p-q)
< T) //
collision
This
requires that you know
p and
q. If you have a large number of obstacles /
pickups, store them in an
std::vector. Then, when performing collision detection
apply the above algorithm for each object
q with the player
p.
A
natural place in the template code to do collision detection is Game::Update().