import pygame
import sys
pygame.init()
width, height = 800, 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("animasyon")
ball_x, ball_y = width // 2, height // 2
ball_speed_x, ball_speed_y = 5, 0
gravity = 0.5
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
ball_speed_y += gravity
ball_x += ball_speed_x
ball_y += ball_speed_y
if ball_x <= 0 or ball_x >= width:
ball_speed_x = -ball_speed_x
if ball_y >= height:
ball_y = height
ball_speed_y = -ball_speed_y * 0.8
screen.fill((255, 255, 255))
pygame.draw.circle(screen, (255, 0, 0), (int(ball_x), int(ball_y)), 20)
pygame.display.flip()
pygame.time.Clock().tick(60)