- Code: Select all
if (circumstance)
{
xvelocity = xvel * gameSpeed;
}//where xvel is a variable that represents xvelocity
- Code: Select all
//for movement
if (moving)
{
switch (direction)
{
case RIGHT:
x += 5 * gameSpeed;
break;
case LEFT:
x -= 5 * gameSpeed;
break;
}
}
//for gravity
if (yvel < maxgrav)//maxgrav is the maximum gravity multiplier - if you make a variable you can adjust it when you are in water etc.
{
yvel += gravstr;
}//gravstr is the increase in gravity, you can adjust it when you want to fall at different rates, like maxgrav
yvelocity = yvel * gameSpeed;
When you have this set up, you can adjust the speed. If you want to go at half the speed, set gameSpeed to .5, or to go at double speed, set it to 2.
You can try other values, like .25, .75, 1.5, etc. You could even make it go backwards (confusing).