-
General Question
Hello all out there
Heres somethig that Ive always been wondering about.
Lets take a simple pac man game.
How does the pac man know when it has been killed or when a collision has taken place.
Im not trying to write a game here but i have always wondered how the detection of collisions etc in the game are picked up by the moving parts as everything is moving at once so how does one know that something has collided.
If you can help in a small explanation thanx
GSLR
-
in most games there's a loop that keeps repeating, updating the game. it happens very frequently. during one of those updates, the program checks to see if the two objects violate each other's boundaries.
-
In games, each sprite or game object generally has a bounding area, like a rectangle in a 2-D game. The game logic checks to see if any bounding areas intersect (collide) with each other and perform the appropriate action. Collision detection systems can get very involved however and generally involve physics equations and lots of math (especially for 3D).
-
thanks
-
For 2D stuff, it's not really that bad though, espcially if you don't let the character rest between tiles. You can simply keep a matrix of information that stores whether or not a particular spot is passable, and everytime the character moves, check if the tile it wants to move into is going to move into a tile that is passable.