# aim_trainer.
py
# Treinador de mira em Pygame
# Autor: ChatGPT (exemplo educativo)
# Execute: python aim_trainer.py
import pygame
import random
import math
import json
import os
from pathlib import Path
# ---------- Configurações ----------
WIDTH, HEIGHT = 1000, 700
FPS = 60
FONT_NAME = None # default font
SAVE_FILE = [Link]() / ".aim_trainer_stats.json"
# ---------- Helper functions ----------
def load_stats():
try:
if SAVE_FILE.exists():
with open(SAVE_FILE, "r") as f:
return [Link](f)
except Exception:
pass
return {"best_accuracy": 0.0, "best_hits": 0}
def save_stats(stats):
try:
with open(SAVE_FILE, "w") as f:
[Link](stats, f)
except Exception:
pass
def dist(a, b):
return [Link](a[0]-b[0], a[1]-b[1])
# ---------- Target class ----------
class Target:
def __init__(self, x, y, radius=30, speed=0, vx=0, vy=0, wobble=0.0,
color=(200,30,30)):
self.x = x
self.y = y
[Link] = radius
[Link] = speed
[Link] = vx
[Link] = vy
[Link] = wobble
[Link] = color
[Link] = True
self.spawn_time = [Link].get_ticks()
def update(self, dt):
# Move with velocity, bounce off edges
self.x += [Link] * dt
self.y += [Link] * dt
if self.x - [Link] < 0:
self.x = [Link]
[Link] *= -1
if self.x + [Link] > WIDTH:
self.x = WIDTH - [Link]
[Link] *= -1
if self.y - [Link] < 0:
self.y = [Link]
[Link] *= -1
if self.y + [Link] > HEIGHT:
self.y = HEIGHT - [Link]
[Link] *= -1
# optional wobble (sinusoidal)
if [Link]:
t = ([Link].get_ticks() - self.spawn_time) / 1000.0
self.x += [Link](t * [Link]) * 0.5
self.y += [Link](t * [Link]) * 0.5
def draw(self, surf):
# Outer ring
[Link](surf, (30,30,30), (int(self.x), int(self.y)),
int([Link]+6))
# Outer color
[Link](surf, [Link], (int(self.x), int(self.y)),
int([Link]))
# Inner bullseye
[Link](surf, (255,255,255), (int(self.x), int(self.y)),
int([Link]*0.35))
def hit_test(self, pos):
return dist(pos, (self.x, self.y)) <= [Link]
# ---------- Game class ----------
class AimTrainer:
def __init__(self):
[Link]()
[Link] = [Link].set_mode((WIDTH, HEIGHT))
[Link].set_caption("Aim Trainer — Educacional")
[Link] = [Link]()
[Link] = [Link](FONT_NAME, 20)
self.large_font = [Link](FONT_NAME, 36)
# Game state
[Link] = []
[Link] = 0
[Link] = 0
self.time_left = 30 # default timed mode seconds
[Link] = "timed" # 'timed'