Skip to main content
GameDev.net gamedev.net
🔒 Locked

collsion detection

Started by crazymonster Jun 19, 2010 at 2:07 AM 1 replies 1.5k views
Original Post
crazymonster
crazymonster
hi guys i am new to game dev and i have one doubt in collision detection in 2d actually my reqirement is i want to have 2 rectangles one will be rotating always and another one wont rotate .so in this case when i am moving to that rotating rectangle i need to know how to find collision and when i am jumping on that rectangle i will be able to walk on that as well as when i am standing on that rotating rectangle for some time i have to slide down i dont know hw to do will someone help on this topics.
grhodes_at_work
grhodes_at_work
Are you primarily concerned with your character (the player) being able to jump on the rectangle that is rotating? And, can your character be idealized as a point, e.g., a point that jumps on the rotating rectangle? (Of course when you draw the character it will be more than a point...maybe triangles or a sprite image...but from a physics point of view, maybe your character is very simple?)

If your character can be idealized as a point, then at a given frame you could consider your character's motion path during that frame to be just a line segment with a starting point at the character's location at the beginning of the frame, and an ending point at the character's unconstrained location at the end of the frame. Check and see if that segment intersects the rectangle...at its instantaneous orientation at the beginning of the frame. If the character line segment intersects, then move the character onto the rectangle.

To actually account for the rotating motion of the rectangle during the frame is trickier to understand and implement. So that is why I am suggesting you do something simple...consider the rectangle to be at a fixed orientation for the duration of the frame, at least for now until your game is more feature complete. You would only update the rectangle's orientation at the end of each frame.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
uralkemal
uralkemal
once i programmed a game like that. just check that out: http://www.pygame.org/project-Balancer-689-.html

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.