-
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,
ethic.
Project: 13h Game.
Compiler: DJGPP.
Operating System: Win95.
-
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.
-
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.