Jul-31-2019, 02:56 AM
i am trying to make a pong game i have started from scratch twice now and i am noticing that the "ball" only bounces if i hover my mouse near the point where it should bounce.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import sys import pygame import os pygame.init() win = pygame.display.set_mode(( 600 , 500 )) pygame.display.set_caption( "pong?" ) win.fill(( 0 , 0 , 0 )) pygame.display.flip() x1 = 305 y1 = 245 xvel = . 05 yvel = . 05 while True : for event in pygame.event.get(): if event. type = = pygame.QUIT: pygame.quit() sys.exit() if y1 > = 490 : yvel * = - 1 pygame.draw.rect(win, ( 255 , 255 , 255 ), (x1, y1, 15 , 15 )) pygame.display.update() x1 + = xvel y1 + = yvel win.fill(( 0 , 0 , 0 )) |