Search found 3 matches
- September 18th, 2017, 12:07 pm
- Forum: Everything
- Topic: A little confusion about tutorial 8 homework solution
- Replies: 4
- Views: 2157
Re: A little confusion about tutorial 8 homework solution
that is correct. Say the value of x is -1 int Game::ClampScreenX(int x, int width) //we're passing -1 to the function { const int dudeRight = x + width; if (x < 0) return 0; // x is -1 which is less than 0 so we return 0 if (dudeRight > gfx.ScreenWidth) return (gfx.ScreenWidth - 1) - width; return ...
- September 18th, 2017, 9:23 am
- Forum: Everything
- Topic: A little confusion about tutorial 8 homework solution
- Replies: 4
- Views: 2157
Re: A little confusion about tutorial 8 homework solution
xOld and yOld gets set to x and y we use clampscreen on x and y if x < 0 then the clamp screen returns 0 now we compare if the xOld is equal to x (0). In this case it is not, meaning that we've hit the wall so the velocity flips. say x is within the screen. Then the clampscreen function will simply...
- September 18th, 2017, 7:57 am
- Forum: Everything
- Topic: A little confusion about tutorial 8 homework solution
- Replies: 4
- Views: 2157
A little confusion about tutorial 8 homework solution
I am confused about the part that makes Poo bounce when it hit the edge const int poo0XOld = poo0X; const int poo0YOld = poo0Y; poo0X = ClampScreenX(poo0X, pooWidth); poo0Y = ClampScreenY(poo0Y, pooHeight); if (poo0X != poo0XOld) poo0SpeedX = -poo0SpeedX; if (poo0Y != poo0YOld) poo0SpeedY = -poo0Sp...