Thread: Help with collision detection

  1. #1
    Registered User
    Join Date
    Jan 2013

    Help with collision detection

    I need help with my collision detection, basically i dont know how to go about it.
    I'm making pacman.
    I've made a 2d array, with 1's for the walls and 0's for the empty spaces I've got pacman to move but dont know how to stop him going through the walls,

    im doing this for Gameboy advance using notepad++ and VisualBoy
    any help would be great thanks

  2. #2
    Registered User
    Join Date
    Jun 2011
    When commanded to move:
     - determine the new x/y coordinates (based on the direction of travel)
     - check those coordinates for an obstacle
     - if no obstacle, move to the new x/y coordinates
     - otherwise, don't move to the new x/y coordinates

  3. #3
    Registered User Dabz's Avatar
    Join Date
    Jan 2013
    Durham, UK
    I use bit-shifting to reduce the players X and Y coordinate to a value that represents a place on the tilemap...

    While not C++ (GLBasic), here's a small example to muse over:-

    But, the code is a little untidy, though, you should be able to pick it apart and tidy it up to suit!


    EDIT: And yeah, I'm a first poster too... Hello everyone!
    Last edited by Dabz; 01-11-2013 at 12:43 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ collision detection
    By ForeverAndOne in forum Game Programming
    Replies: 2
    Last Post: 10-09-2011, 04:08 PM
  2. Collision detection
    By jack_carver in forum C Programming
    Replies: 5
    Last Post: 02-08-2010, 06:52 AM
  3. Collision Detection.
    By zergdeath1 in forum C++ Programming
    Replies: 5
    Last Post: 11-21-2004, 05:28 PM
  4. collision detection
    By DavidP in forum Game Programming
    Replies: 2
    Last Post: 05-11-2002, 01:31 PM
  5. Need collision detection!(HELP!)
    By SyntaxBubble in forum Game Programming
    Replies: 1
    Last Post: 02-27-2002, 06:13 PM