├── README.md └── tutorial.py /README.md: -------------------------------------------------------------------------------- 1 | # Python-Aim-Trainer 2 | 3 | # 💻 Launch Your Software Development Career Today! 4 | 5 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 6 | 7 | 🚀 **Why Join?** 8 | - 💼 **$70k+ starting salary potential** 9 | - 🕐 **Self-paced:** Complete on your own time 10 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 11 | - 🎯 **45,000+ job openings** in the market 12 | 13 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 14 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 15 | -------------------------------------------------------------------------------- /tutorial.py: -------------------------------------------------------------------------------- 1 | import math 2 | import random 3 | import time 4 | import pygame 5 | pygame.init() 6 | 7 | WIDTH, HEIGHT = 800, 600 8 | 9 | WIN = pygame.display.set_mode((WIDTH, HEIGHT)) 10 | pygame.display.set_caption("Aim Trainer") 11 | 12 | TARGET_INCREMENT = 400 13 | TARGET_EVENT = pygame.USEREVENT 14 | 15 | TARGET_PADDING = 30 16 | 17 | BG_COLOR = (0, 25, 40) 18 | LIVES = 3 19 | TOP_BAR_HEIGHT = 50 20 | 21 | LABEL_FONT = pygame.font.SysFont("comicsans", 24) 22 | 23 | 24 | class Target: 25 | MAX_SIZE = 30 26 | GROWTH_RATE = 0.2 27 | COLOR = "red" 28 | SECOND_COLOR = "white" 29 | 30 | def __init__(self, x, y): 31 | self.x = x 32 | self.y = y 33 | self.size = 0 34 | self.grow = True 35 | 36 | def update(self): 37 | if self.size + self.GROWTH_RATE >= self.MAX_SIZE: 38 | self.grow = False 39 | 40 | if self.grow: 41 | self.size += self.GROWTH_RATE 42 | else: 43 | self.size -= self.GROWTH_RATE 44 | 45 | def draw(self, win): 46 | pygame.draw.circle(win, self.COLOR, (self.x, self.y), self.size) 47 | pygame.draw.circle(win, self.SECOND_COLOR, 48 | (self.x, self.y), self.size * 0.8) 49 | pygame.draw.circle(win, self.COLOR, (self.x, self.y), self.size * 0.6) 50 | pygame.draw.circle(win, self.SECOND_COLOR, 51 | (self.x, self.y), self.size * 0.4) 52 | 53 | def collide(self, x, y): 54 | dis = math.sqrt((x - self.x)**2 + (y - self.y)**2) 55 | return dis <= self.size 56 | 57 | 58 | def draw(win, targets): 59 | win.fill(BG_COLOR) 60 | 61 | for target in targets: 62 | target.draw(win) 63 | 64 | 65 | def format_time(secs): 66 | milli = math.floor(int(secs * 1000 % 1000) / 100) 67 | seconds = int(round(secs % 60, 1)) 68 | minutes = int(secs // 60) 69 | 70 | return f"{minutes:02d}:{seconds:02d}.{milli}" 71 | 72 | 73 | def draw_top_bar(win, elapsed_time, targets_pressed, misses): 74 | pygame.draw.rect(win, "grey", (0, 0, WIDTH, TOP_BAR_HEIGHT)) 75 | time_label = LABEL_FONT.render( 76 | f"Time: {format_time(elapsed_time)}", 1, "black") 77 | 78 | speed = round(targets_pressed / elapsed_time, 1) 79 | speed_label = LABEL_FONT.render(f"Speed: {speed} t/s", 1, "black") 80 | 81 | hits_label = LABEL_FONT.render(f"Hits: {targets_pressed}", 1, "black") 82 | 83 | lives_label = LABEL_FONT.render(f"Lives: {LIVES - misses}", 1, "black") 84 | 85 | win.blit(time_label, (5, 5)) 86 | win.blit(speed_label, (200, 5)) 87 | win.blit(hits_label, (450, 5)) 88 | win.blit(lives_label, (650, 5)) 89 | 90 | 91 | def end_screen(win, elapsed_time, targets_pressed, clicks): 92 | win.fill(BG_COLOR) 93 | time_label = LABEL_FONT.render( 94 | f"Time: {format_time(elapsed_time)}", 1, "white") 95 | 96 | speed = round(targets_pressed / elapsed_time, 1) 97 | speed_label = LABEL_FONT.render(f"Speed: {speed} t/s", 1, "white") 98 | 99 | hits_label = LABEL_FONT.render(f"Hits: {targets_pressed}", 1, "white") 100 | 101 | accuracy = round(targets_pressed / clicks * 100, 1) 102 | accuracy_label = LABEL_FONT.render(f"Accuracy: {accuracy}%", 1, "white") 103 | 104 | win.blit(time_label, (get_middle(time_label), 100)) 105 | win.blit(speed_label, (get_middle(speed_label), 200)) 106 | win.blit(hits_label, (get_middle(hits_label), 300)) 107 | win.blit(accuracy_label, (get_middle(accuracy_label), 400)) 108 | 109 | pygame.display.update() 110 | 111 | run = True 112 | while run: 113 | for event in pygame.event.get(): 114 | if event.type == pygame.QUIT or event.type == pygame.KEYDOWN: 115 | quit() 116 | 117 | 118 | def get_middle(surface): 119 | return WIDTH / 2 - surface.get_width()/2 120 | 121 | 122 | def main(): 123 | run = True 124 | targets = [] 125 | clock = pygame.time.Clock() 126 | 127 | targets_pressed = 0 128 | clicks = 0 129 | misses = 0 130 | start_time = time.time() 131 | 132 | pygame.time.set_timer(TARGET_EVENT, TARGET_INCREMENT) 133 | 134 | while run: 135 | clock.tick(60) 136 | click = False 137 | mouse_pos = pygame.mouse.get_pos() 138 | elapsed_time = time.time() - start_time 139 | 140 | for event in pygame.event.get(): 141 | if event.type == pygame.QUIT: 142 | run = False 143 | break 144 | 145 | if event.type == TARGET_EVENT: 146 | x = random.randint(TARGET_PADDING, WIDTH - TARGET_PADDING) 147 | y = random.randint( 148 | TARGET_PADDING + TOP_BAR_HEIGHT, HEIGHT - TARGET_PADDING) 149 | target = Target(x, y) 150 | targets.append(target) 151 | 152 | if event.type == pygame.MOUSEBUTTONDOWN: 153 | click = True 154 | clicks += 1 155 | 156 | for target in targets: 157 | target.update() 158 | 159 | if target.size <= 0: 160 | targets.remove(target) 161 | misses += 1 162 | 163 | if click and target.collide(*mouse_pos): 164 | targets.remove(target) 165 | targets_pressed += 1 166 | 167 | if misses >= LIVES: 168 | end_screen(WIN, elapsed_time, targets_pressed, clicks) 169 | 170 | draw(WIN, targets) 171 | draw_top_bar(WIN, elapsed_time, targets_pressed, misses) 172 | pygame.display.update() 173 | 174 | pygame.quit() 175 | 176 | 177 | if __name__ == "__main__": 178 | main() 179 | --------------------------------------------------------------------------------