Fogos de Artifício
import tkinter as tk import random class Firework: def __init__ ( self , canvas , x , y): self .canvas = canvas self .x = x self .y = y self .particles = [] self .create_firework() def create_firework ( self ): # Criar uma explosão de partículas for _ in range ( 50 ): # Número de partículas angle = random.uniform( 0 , 2 * 3.14159 ) # Ângulo aleatório speed = random.uniform( 1 , 5 ) # Velocidade aleatória particle = { 'x' : self .x , 'y' : self .y , 'dx' : speed * random.uniform(- 1 , 1 ) , # Movimento em X 'dy' : speed * random.uniform(- 1 , - 3 ) , # Movimento em Y 'color' : random.choice([ 'red' , 'blue' , 'green' , 'yellow' , 'purple' , 'orange' ]) , 'size' : random.randint( 5 , 10 ) ...