I'm making a simple game where I bounce and image off the sides of the screen (a bit like the ball bounces in Pong) but I can't seem to the the bouncing part to work. Instead of bouncing of the edges of the screen it is going right through it. The related code is below:
while (mainloop):
milliseconds = clock.tick(FPS)
seconds = 1 / float(milliseconds)
square.loc_x += 35 * seconds
square.loc_y += 35 * seconds
# I'm guessing the problem lies in the code below but I can't seem to spot it
if square.loc_y >= 440 or square.loc_y <= 1:
print square.loc_y >= 440 or square.loc_y <= 1
square.loc_change_y = square.loc_change_y * -1 * seconds
elif square.loc_x >= 600 or square.loc_x <= 1:
print square.loc_y >= 440 or square.loc_y <= 1
square.loc_change_x = square.loc_change_x * -1 * seconds
square.loc_x += square.loc_change_x * seconds
square.loc_y += square.loc_change_y * seconds