Thread: Asteroids-like collision detection/physics & rounding speed

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476

    Asteroids-like collision detection/physics & rounding speed

    Basically there are two problems. The first one is easy (in a 2D world):

    The entities in the project have positions stored as float points. But a screen has only ints as pixels. So, is rounding floats to ints appropriate? Since if I just take the floor, the objects move sloppy (stays the same, then jumps, stays the same etc). What would you do?

    The second one not so easy:

    So, let's say the players (spaceships) have position, rotation, scale and a center. If a player touches the screen borders, it should bounce realistically. For example:

    assume the player looks like a giant 'U'.

    Code:
    |   |
    |   |
    |___|
    if it's rotated 45 degrees to the right and collides with the top, like

    Code:
    __________
        X
       /
      /
     / C /
     \  /
      \/
    (Where X is the point of collision and C the mass center of the object)

    In this case, the point X is a bit to the right of C, so the object should rotate a bit to the right and be pushed down.

    There is a force acting directly down from point X (ignore friction for now). How should I implement this?


    So, the basic idea is implementing forces with a position and direction. But how to calculate the resulting rotation/translation of the object? I think this needs some trig. Don't matter.

    My ideas are:
    If the force's direction vector points to the center of an object (beginning at the force point), the translation is equal to the direction and the rotation is none. But if the vector points 90 degrees to the left/right, the translation is none and there is only rotation.
    Last edited by Brafil; 07-28-2009 at 10:30 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Some collision handling fun
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 04-13-2008, 08:45 AM
  2. Collision Detection Problems
    By Dark_Phoenix in forum Game Programming
    Replies: 1
    Last Post: 12-17-2006, 03:25 PM
  3. Collision Detection
    By Grantyt3 in forum C++ Programming
    Replies: 3
    Last Post: 09-30-2005, 03:21 PM
  4. collision detection
    By DavidP in forum Game Programming
    Replies: 2
    Last Post: 05-11-2002, 01:31 PM
  5. Replies: 4
    Last Post: 05-03-2002, 09:40 PM