having problems making them stay in the boundares of my screen, i also cant figure out how to get collision from my ball but ill try and figure that out myself, this on the other hand has had me stuck for the past 2 days and i really would like some help solving my problem =D
here are my current restraints for my paddles for the game pong that i am desiging in visual studio 2010.
if(leftpaddle_2y < 0)
leftpaddle_2y = 0;
if(leftpaddle_2x + 5 > 768)
leftpaddle_2x = 763;
if (rightpaddle_1y < 0)
rightpaddle_1y = 0;
now padels wont leave the top right and left corners of the screen but i cant get them to stay on the bottom right and left parts of the screen.
Well that's because there doesn't appear to be a check for the bottom boundary against the y value of the paddles.
It'll depend on your window height, but it'll look something like this:
1 2 3 4
if (bottom_of_left_paddle > window_height)
{
bottom_of_left_paddle = window_height;
}
Remember that in most 2D game coordinate systems, the y coordinates go from top to bottom.
Also, the check on the x value would appear redundant as, traditionally, pong paddles can only move up and down. The x coordinates should only really be relevant in ball collision.