Page 1 of 1

tutorial 8 homework(BEGINNER)

Posted: February 24th, 2018, 3:20 pm
by dooomedstar
https://www.youtube.com/watch?v=KIw8MX7 ... BHBFFRVWsx
in the video 2:45

poo0X += poo0vx;
poo0Y += poo0vy;

poo1X += poo1vx;
poo1Y += poo1vy;

poo2X += poo2vx;
poo2Y += poo2vy;
{
const int poo0xold = poo0X;
const int poo0yold = poo0Y;
poo0X = ClampScreenX(poo0X, poowidth);
poo0Y = ClampScreenY(poo0Y, pooheight);
if(poo0X != poo0xold)
{
poo0vx = -poo0vx;

}
if (poo0Y != poo0yold)
{
poo0vy = -poo0vy;

}

I have highlighted my doubt in red, we set poo0old to poo0X, why after clamping the position of the poo changes? I mean how poo after clamping is different than the poo before clamping. both the variables have to be same all the time right. This is the part i don't understand. Hope anyone in this wonderful community could enlighten this poor boi.

Re: tutorial 8 homework(BEGINNER)

Posted: February 24th, 2018, 5:30 pm
by chili
They don't have to be the same. The whole point of clamping is to adjust the position of the poo so that it is no longer sticking outside of the screen region. So if clamping occurs, the position will change, and then it will not be equal to the old position.

Re: tutorial 8 homework(BEGINNER)

Posted: February 24th, 2018, 6:48 pm
by dooomedstar
oh thanks chilli, i get it now, after bouncin the mofo poo off the screen, the poo0X and poo0old is equal rite?? thank you for the enlightment.

Re: tutorial 8 homework(BEGINNER)

Posted: February 25th, 2018, 1:33 am
by chili
Nah, if a bounce occurs, that means an adjustment occurred, so that would be precisely the the time that they are not equal. They would remain equal all other times.