How i can write the logic code to move a ball in pong game in pygame. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How i can write the logic code to move a ball in pong game in pygame.

25th Feb 2019, 3:43 AM
Maninder $ingh
Maninder $ingh - avatar
2 Answers
+ 5
tha ball have x pos, y pos, x speed and y speed, if the x pos is less than 0 x pos set to 0 and x speed set to - xspeed, if the ball x is greater than the screen width, the ball x set to the screen width and x speed set to - xspeed. The same in y pos and y speed.
25th Feb 2019, 6:10 AM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar
+ 3
try to write collisions to players you with the same logic
25th Feb 2019, 6:11 AM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar