# Collision

I’m currently coding a micro-machines clone. Does anyone know how I
could code a flexible collision system? I can’t get anything better than
horizantal and vertical lines for collision. The problem is that I want
to know how the cars bump off the wall, and not only if they hit the
wall.

Thank for any help, Karl.

you could take the direction the object is travelling and its speed and
calculate reflective colisions from the wall with that info

Michael Lunnay

you could take the direction the object is travelling and its speed and
calculate reflective colisions from the wall with that info

Michael Lunnay

That’s clear. But how can I assign the correct lines to every object? I
just can’t find a data structure that is well usable. And what to do if
one line of object #1 hits two lines of object #2? What should I
calculate now?
I just thought someone in this list has done something like this before.

In founts I set up a bitmap where each point is either 0 (empty) or !=0
in which case it points to a structure telling the direction of the surface.
The objects moving check the bitmap–if they end up on top of a !=0 point
they’ve hit something and they know how to rebound.

Doesn’t deal with corners very well though. Maybe you could have a special
corner structure that is circular.

“Dave Ashley (SDL list)” wrote:

In founts I set up a bitmap where each point is either 0 (empty) or !=0
in which case it points to a structure telling the direction of the surface.
The objects moving check the bitmap–if they end up on top of a !=0 point
they’ve hit something and they know how to rebound.
That’s a good idea, thanks. I like the collision in founts. Is there a
fast and easy way to greate these bitmaps? I’ll have to create a lot of
tiles with collision, so it shouldn’t be too complicated. Any
suggestion?

Doesn’t deal with corners very well though. Maybe you could have a special
corner structure that is circular.
That’s no problem. I’ve already used such a collision in BumpRace.

Karl