Walking on ice

Talk about making games.

Walking on ice

Postby jimmynewguy » Wed Apr 09, 2008 8:38 pm

:evil: I've tried and tried, but i just can't make it seem like my platform character is on ice :oops:
is there any way to do this.... I don't care if its not simple and if you don't understand what i mean well....
- the character accelerates in the direction he's going
- the character slso slides on key up

i can do it, but it seems choppy like he will go from here - to here - in just a second
:lol:

plz help :mrgreen:
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Walking on ice

Postby DilloDude » Wed Apr 09, 2008 9:48 pm

Here's where something like a 'traction' variable comes in hanbdy. It can be adjusted depending on what type of ground you're on, if you want different types of ground. Otherwise, you can generally hardcode it in.
You need to adjust xvelocity, or another variable that simulates xvelocity. Something like this:
Code: Select all
if (moving_right)//some condition when you should be moving right
{
    if (xvelocity < 5)
    {
        xvelocity += traction;
    }
    else
    {
        xvelocity = 5;
    }
}
else if (moving_left)
{
    if (xvelocity > -5)
    {
        xvelocity -= traction;
    }
    else
    {
        xvelocity = -5;
    }
}
else // when not moving, you should slow down
{
    if (xvelocity >= traction)
    {
        xvelocity -= traction;
    }
    else if (xvelocity < -traction)
    {
        xvelocity += traction;
    }
    else
    {
        xvelocity = 0;
    }
}
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Walking on ice

Postby jimmynewguy » Thu Apr 10, 2008 12:52 am

thanx, i also discoverd another way, points ++ anway :D , where collision on ice = physical response of .6 for both actors creating a sliding effect
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron