09-11-2002, 03:31 PM
Thanks for repling to my question ! The game
I am trying to make is a side scrolling 2d
dirt bike game. It will just Be some cheese
game like a simple bike with some jumps. If you could give me some clue on how to get started on some collision detection I would be very thankful.
thanks again flyer
09-11-2002, 06:02 PM
2D collision detection is realy easy.
Say your in ortho view with an 800*600 window. Your screen coords will now direcly map your actual coords. So first start by making a bounding square around your objects. Like the bike, if the center of the bike was at 2,1 on the screen and it was 4 units long, by 2 high, its square could be 0,0 4,2. (You only need 2 verts, lower left, and upper right, to define a rectangle.) Now the bike is contained in that box on the screen. Now if the bike moves forward (x direction) 10 pixels on the screen, the box would too, so it would now be 10,0 14,2. This is VERY usefull.
Now each frame, all you have to do is check that NO box is overlapping. If 2 of the bounding boxes over lap, then you have a collision. This is the SIMPLEST form of 2D collision detection. Now things like ramps and such, could be done with 2D vectors. But I dont realy have time to go into that tonight. Let me know how you are comming along. I will post more later.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.