-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Description
import pygame
import random
import time
Inicializa o pygame
pygame.init()
Configurações da janela
LARGURA, ALTURA = 800, 600
janela = pygame.display.set_mode((LARGURA, ALTURA))
pygame.display.set_caption("Treinador de Mira - Free Fire")
Cores
BRANCO = (255, 255, 255)
VERMELHO = (255, 0, 0)
PRETO = (0, 0, 0)
Fonte
fonte = pygame.font.SysFont("Arial", 30)
Variáveis de jogo
raio = 30
pontos = 0
alvo_x = random.randint(raio, LARGURA - raio)
alvo_y = random.randint(raio, ALTURA - raio)
tempo_inicio = time.time()
tempo_reacao = 0
Loop do jogo
rodando = True
while rodando:
janela.fill(BRANCO)
# Desenha o alvo
pygame.draw.circle(janela, VERMELHO, (alvo_x, alvo_y), raio)
# Mostra pontuação
texto_pontos = fonte.render(f"Pontos: {pontos}", True, PRETO)
janela.blit(texto_pontos, (10, 10))
if tempo_reacao > 0:
texto_tempo = fonte.render(f"Reação: {tempo_reacao:.2f}s", True, PRETO)
janela.blit(texto_tempo, (10, 50))
pygame.display.update()
for evento in pygame.event.get():
if evento.type == pygame.QUIT:
rodando = False
# Clique do mouse
if evento.type == pygame.MOUSEBUTTONDOWN:
mouse_x, mouse_y = pygame.mouse.get_pos()
distancia = ((mouse_x - alvo_x) ** 2 + (mouse_y - alvo_y) ** 2) ** 0.5
if distancia <= raio: # Acertou o alvo
pontos += 1
tempo_reacao = time.time() - tempo_inicio
# Gera novo alvo
alvo_x = random.randint(raio, LARGURA - raio)
alvo_y = random.randint(raio, ALTURA - raio)
tempo_inicio = time.time()
pygame.quit()
Metadata
Metadata
Assignees
Labels
No labels