Thursday, March 5, 2015

Ping pong game, ball moving like classic

I think this line of code has the problem:



if (Ball_objekt.Bottom >= Player_objekt.Top && Ball_objekt.Bottom <= Player_objekt.Bottom && Ball_objekt.Top >= Player_objekt.Top && Ball_objekt.Right <=Player_objekt.Right)

The ball according to this only bounces back if it is on the left side of the player object, is that what you want?


Maybe the heights of ball and/or player are creating the problem.


What are the height of ball and player objects?


Can you try this code?



if(Ball_objekt.Bottom >= Player_objekt.Top
&&
Ball_objekt.Bottom <= Player_objekt.Bottom
)



No comments:

Post a Comment