tutorial 8 homework(BEGINNER)

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
dooomedstar
Posts: 3
Joined: February 5th, 2018, 4:17 pm

tutorial 8 homework(BEGINNER)

Post by dooomedstar » February 24th, 2018, 3:20 pm

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.
Image

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: tutorial 8 homework(BEGINNER)

Post by chili » February 24th, 2018, 5:30 pm

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.
Chili

dooomedstar
Posts: 3
Joined: February 5th, 2018, 4:17 pm

Re: tutorial 8 homework(BEGINNER)

Post by dooomedstar » February 24th, 2018, 6:48 pm

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.
Image

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: tutorial 8 homework(BEGINNER)

Post by chili » February 25th, 2018, 1:33 am

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.
Chili

Post Reply