Page 1 of 1

Caps on Y-Direction movement?

PostPosted: Fri Aug 17, 2007 2:17 am
by d-soldier
int weight = 20;
y = ((weight -1)*y + player_box.y-60)/weight;

Is there a way to re-script this so it will only move between y600 and y4000? I'm trying not to use collision-events if not needed.

PostPosted: Fri Aug 17, 2007 4:13 am
by DilloDude
A simple way is to just put
Code: Select all
if (y < 600)
{
    y = 600;
}
else if (y > 4000)
{
    y = 4000;
}

after it.

PostPosted: Fri Aug 17, 2007 2:06 pm
by d-soldier
... It's always the "simple way" that never even occurs to me... Thanks!

PostPosted: Sat Aug 18, 2007 1:11 am
by Fuzzy
you can also take your range (4000-600) or 3400 and use it as a modulus, then add the minimum range back in... if you want to wrap around the screen.

y= (y % 3400) + 600; // y = 4000 becomes y = 600