Results 1 to 3 of 3

Thread: 2D Collision System

  1. #1
    Join Date
    Apr 2011

    Default 2D Collision System

    I have just begun using Clanlib and was curious about implementing an efficient collision system for a two-dimensional game I am attempting to create. In essence, it consists of a single player walking on the x-y plane. There are also a significant amount of collision objects within the area. Reading the documentation regarding the built-in Clanlib collision detection it sounds like the program is going to constantly have to check the player's outlines with those of each object within the area individually. Is this the most efficient method? Or is there a method which will allow the program to arbitrarily check to determine whether any collision has been detected with the player.

    I couldn't imagine that in production-quality games the player's outlines would have to be checked against the outlines of all of the objects within the zone every time the player moves.
    Last edited by Lars; 05-03-2011 at 12:14 AM.

  2. #2
    Master Sorcerer
    Join Date
    Sep 2006


    It depends on the complexity of the problem. If you have fairly few objects then just using a brute force approach may work just fine.

    The typical way to deal with many objects with high complexity is to use bounding boxes, planes, tree structures and other simple measures to quickly exclude a big set of objects.

    For example, if the two bounding boxes do not overlap then there's no point in checking in more detail. If even checking the bounding boxes take too long time, the next step could be to split the scene into two planes (i.e. left side of the map and the right side). Then by one simple check you already excluded half the scene. If its still too much you can do more and more fine-grained checking.

  3. #3
    ClanLib Developer
    Join Date
    Sep 2006
    Bergen, Norway


    Just a note and as far as a I know, the ClanLib collision system does quick boundschecking before going into detailed collision checking using the outline itself.

    Anyway, as Magnus mentions, partioning your scene might be neccessary if you have alot of objects. There are many ways to do this - some are outlined here.

Similar Threads

  1. Using GUI system
    By JoseMan in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 05-26-2010, 05:53 AM
  2. gui system
    By koloska in forum Novashell Game Creation System
    Replies: 2
    Last Post: 06-08-2009, 11:57 PM
  3. Dialog System?
    By rgrwkmn in forum Novashell Game Creation System
    Replies: 5
    Last Post: 12-22-2008, 12:29 AM
  4. Build System ?
    By zyklo in forum Official ClanLib SDK Forums
    Replies: 10
    Last Post: 09-22-2008, 02:00 PM
  5. Payment system
    By in forum Funeral Quest
    Replies: 0
    Last Post: 12-15-2002, 07:46 AM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts