Thread: Walking on a surface...

  1. #1
    Join Date
    Aug 2001

    Walking on a surface...

    Anyway, how is this done? My game consists of
    one background, but the character walks back and
    forth across the screen. 'D' moves right, and
    'A' moves left.

    I would like the character's movement to be
    somewhat realistic. I don't just want to
    increment/decrement the xposition when a key
    is pressed. How can I go about making the
    character walk across an uneven surface? A
    surface that contains little hills and things?

    Thanks a lot,

    Project: 13h Game.
    Compiler: DJGPP.
    Operating System: Win95.
    Staying away from General.

  2. #2
    Registered User
    Join Date
    Oct 2001
    There are as many ways to do this as you can be creative. One way would be to use collision detection with your character and the ground. Possibly by outlining ground objects with a certain special color and then testing for that color at a collision point. Another would be to map out just the ground as a simple array map. This can speed up collision detection as you have a simpler reference for where your character can be at any given time and place.
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland:

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    For 3D grids, you need to find the height values of the four corners of the cell that your character is in. Second you need to find how far 'into' the cell your character is. Then using these two floating point values you can do a bilinear interpolation to find out how high the ground is where you character is walking and adjust his y value accordingly (or the correct axis for your seup).

    Bilinear is slow, but you might be able to shoot this to the hardware to get it done fast, or you may want to code it in assembly using the FPU. I've coded a bilinear in asm and it's super fast, but hardware would be even faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL: How to make surface shiny
    By ting in forum Game Programming
    Replies: 6
    Last Post: 06-18-2008, 05:09 PM
  2. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  3. Please help with my game
    By jjj93421 in forum Game Programming
    Replies: 10
    Last Post: 04-12-2004, 11:38 PM
  4. Replies: 3
    Last Post: 08-14-2003, 01:37 PM