import pygame
import sys
import time
pygame.init()
screen = pygame.display.set_mode((700, 600))
ball_x = 350
ball_y = 300
ban_x, ban_y, ban_k, ban_g = 350, 530, 200, 70
pygame.key.set_repeat(1,1)
while True:
for event in pygame.event.get():
print(event)
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_a:
ban_x = ban_x - 1
if event.key == pygame.K_d:
ban_x = ban_x + 1
screen.fill((0, 0, 100))
ball_y = ball_y + 1
if ball_y > 600:
ball_y = 0
if ban_x < 0:
ban_x = 0
if ban_x > 600:
ban_x = 600
if ban_y < -70:
ban_y = 600
pygame.draw.circle(screen, (0, 245, 255), (ball_x, ball_y), 50)
pygame.draw.rect(screen, (170, 182, 1), (ban_x, ban_y, ban_k, ban_g))
pygame.display.update()
time.sleep(0.001)