Untitled

Plain Text 2026-09-17 08:13 51 views
ID: kGVUVLII
Raw
Untitled.txt
51 lines • 1517 chars • 1.54 KB
import pygame
import math

pygame.init()
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Aim Trainer - Game của bạn")
clock = pygame.time.Clock()

# Mục tiêu
target = pygame.Rect(400, 300, 40, 40)
radius = 30  # bán kính vòng tròn ngắm

# Điểm
score = 0
font = pygame.font.SysFont("Arial", 24)

running = True
while running:
    screen.fill((30, 30, 40))
    mx, my = pygame.mouse.get_pos()
    
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        if event.type == pygame.MOUSEBUTTONDOWN:
            # Kiểm tra chuột có nằm trong mục tiêu không
            if target.collidepoint(mx, my):
                score += 1
                # Random vị trí mới
                import random
                target.x = random.randint(50, WIDTH - 90)
                target.y = random.randint(50, HEIGHT - 90)
    
    # Vẽ mục tiêu
    pygame.draw.rect(screen, (255, 80, 80), target, border_radius=8)
    
    # Vẽ vòng tròn ngắm theo chuột
    pygame.draw.circle(screen, (0, 255, 150), (mx, my), radius, 2)
    # Tâm ngắm
    pygame.draw.line(screen, (0, 255, 150), (mx - 15, my), (mx + 15, my), 2)
    pygame.draw.line(screen, (0, 255, 150), (mx, my - 15), (mx, my + 15), 2)
    
    # Hiển thị điểm
    text = font.render(f"Điểm: {score}", True, (255, 255, 255))
    screen.blit(text, (10, 10))
    
    pygame.display.flip()
    clock.tick(60)

pygame.quit()
Notification
Continue with Discord Continue with Google
Don't have an account? Register on Auth Platform