Caps on Y-Direction movement?

You must understand the Game Editor concepts, before post here.

Caps on Y-Direction movement?

Postby d-soldier » Fri Aug 17, 2007 2:17 am

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.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby DilloDude » Fri Aug 17, 2007 4:13 am

A simple way is to just put
Code: Select all
if (y < 600)
{
    y = 600;
}
else if (y > 4000)
{
    y = 4000;
}

after it.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby d-soldier » Fri Aug 17, 2007 2:06 pm

... It's always the "simple way" that never even occurs to me... Thanks!
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Fuzzy » Sat Aug 18, 2007 1:11 am

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
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest