Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/68c9bd38-1494-8003-92de-0fcfb17eb8dc
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: Perfeito! === Perfeito! Aqui está o código completo atualizado para celular, com partículas se movendo suavemente, força passiva suficiente para flutuação, botões grandes e controles visíveis: <syntaxhighlight lang="python">import pygame import math import random === --- Inicialização --- === pygame.init() WIDTH, HEIGHT = 1200, 800 # tela maior screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Cúpulas Químicas - Movimento Suave") clock = pygame.time.Clock() font = pygame.font.SysFont(None, 30) TILE_SIZE = 40 === cores base === ATTRACT = (255, 50, 50) REPEL = (50, 50, 255) NEUTRAL = (180,180,180) COIL = (255,165,0) ALCHEMY = (255,255,100) BUTTON_COLOR = (50,50,50) BUTTON_TEXT_COLOR = (255,255,255) === mosaico === mosaic = [] for i in range(WIDTH // TILE_SIZE): row = [] for j in range(HEIGHT // TILE_SIZE): choices = random.choices([ATTRACT, REPEL, NEUTRAL], [0.3,0.3,0.4], k=random.choice([1,2])) row.append(choices) mosaic.append(row) === --- Parâmetros ajustáveis --- === time_factor = 1.0 force_strength = 300.0 # força passiva suficiente root_range = 180.0 damping_center = 0.97 damping_normal = 0.99 class Particle: def __init__(self, x, y, kind="ATTRACT", mass=1, radius=18, is_coil=False): self.x = x self.y = y self.kind = kind self.vx = random.uniform(-120,120) self.vy = random.uniform(-120,120) self.mass = mass self.radius = radius self.is_coil = is_coil self.inner_particles = [] def draw(self, screen): if self.is_coil: color = COIL elif self.kind=="ATTRACT": color = ATTRACT elif self.kind=="REPEL": color = REPEL else: color = NEUTRAL pygame.draw.circle(screen,color,(int(self.x),int(self.y)),self.radius) for p in self.inner_particles: pygame.draw.circle(screen,ALCHEMY,(int(p[0]),int(p[1])),5) def update(self, dt, center, particles, force_strength, root_range): for p in particles: if p==self: continue dx = p.x - self.x dy = p.y - self.y dist = math.hypot(dx, dy) if dist==0: dist=0.1 # Atração/Repulsão passiva if self.kind=="ATTRACT" and dist<root_range: force = force_strength/dist self.vx += dx/dist''force''dt self.vy += dy/dist''force''dt elif self.kind=="REPEL" and dist<root_range: force = force_strength/dist self.vx -= dx/dist''force''dt self.vy -= dy/dist''force''dt elif self.kind=="NEUTRAL" and dist<root_range/2: force = force_strength/(dist*2) self.vx -= dx/dist''force''dt self.vy -= dy/dist''force''dt # Centro como jockey dx_center = center[0]-self.x dy_center = center[1]-self.y dist_center = math.hypot(dx_center,dy_center) if dist_center<50: self.vx *= damping_center self.vy *= damping_center else: self.vx *= damping_normal self.vy *= damping_normal self.x += self.vx*dt self.y += self.vy*dt self.x = max(self.radius,min(WIDTH-self.radius,self.x)) self.y = max(self.radius,min(HEIGHT-self.radius,self.y)) # partículas internas new_inner=[] for p in self.inner_particles: px,py,vx,vy,life = p life -= dt if life>0: px += vx*dt py += vy*dt new_inner.append([px,py,vx,vy,life]) self.inner_particles = new_inner def emit_inner(self,n=15): for _ in range(n): angle=random.uniform(0,2*math.pi) speed=random.uniform(150,300) vx = math.cos(angle)*speed vy = math.sin(angle)*speed life = random.uniform(0.8,1.5) self.inner_particles.append([self.x,self.y,vx,vy,life]) === setup === particles=[ Particle(600,400,"ATTRACT"), Particle(300,300,"REPEL"), Particle(900,500,"NEUTRAL"), Particle(600,650,is_coil=True) ] center = (WIDTH//2, HEIGHT//2) === --- Botões de controle maiores --- === buttons = [ {"label":"+Tempo","rect":pygame.Rect(20,20,150,60),"action":"time_up"}, {"label":"-Tempo","rect":pygame.Rect(190,20,150,60),"action":"time_down"}, {"label":"+Força","rect":pygame.Rect(20,100,150,60),"action":"force_up"}, {"label":"-Força","rect":pygame.Rect(190,100,150,60),"action":"force_down"}, {"label":"+Alcance","rect":pygame.Rect(20,180,150,60),"action":"range_up"}, {"label":"-Alcance","rect":pygame.Rect(190,180,150,60),"action":"range_down"}, {"label":"Emitir","rect":pygame.Rect(20,260,320,60),"action":"emit"} ] running = True while running: dt = clock.tick(60)/1000 dt *= time_factor for event in pygame.event.get(): if event.type==pygame.QUIT: running=False elif event.type==pygame.MOUSEBUTTONDOWN: mx,my = event.pos for b in buttons: if b["rect"].collidepoint(mx,my): if b["action"]=="time_up": time_factor *=1.2 elif b["action"]=="time_down": time_factor /=1.2 elif b["action"]=="force_up": force_strength *=1.2 elif b["action"]=="force_down": force_strength /=1.2 elif b["action"]=="range_up": root_range *=1.2 elif b["action"]=="range_down": root_range /=1.2 elif b["action"]=="emit": for p in particles: if p.is_coil: p.emit_inner(20) # adicionar partículas clicando fora dos botões if my>350: kind=random.choice(["ATTRACT","REPEL","NEUTRAL"]) particles.append(Particle(mx,my,kind)) for p in particles: p.update(dt,center,particles,force_strength,root_range) # desenhar mosaico for i in range(len(mosaic)): for j in range(len(mosaic[0])): cell = mosaic[i][j] if len(cell)==1: color = cell[0] else: color = tuple(min(255,sum(c)//len(c)) for c in zip(*cell)) pygame.draw.rect(screen,color,(i''TILE_SIZE,j''TILE_SIZE,TILE_SIZE,TILE_SIZE)) # desenhar partículas for p in particles: p.draw(screen) # desenhar centro pygame.draw.circle(screen,(50,50,50),center,7) # desenhar botões for b in buttons: pygame.draw.rect(screen,BUTTON_COLOR,b["rect"]) txt = font.render(b["label"],True,BUTTON_TEXT_COLOR) screen.blit(txt,(b["rect"].x+10,b["rect"].y+15)) # mostrar valores atuais info = font.render(f"Tempo:{time_factor:.2f} Força:{force_strength:.1f} Alcance:{root_range:.1f}",True,(0,0,0)) screen.blit(info,(10,HEIGHT-40)) pygame.display.flip() pygame.quit() </syntaxhighlight> ===== 1. Força aumentada para 300 → partículas se movem visivelmente, mas ainda suavemente. ===== # Amortecimento reduzido (damping_center = 0.97, damping_normal = 0.99) → partículas continuam flutuando. # Botões maiores para toque confortável no celular. # Partículas internas maiores → melhor visualização do efeito da bobina. # Tela maior: 1200x800, mais espaço para o movimento. Se quiser, posso adicionar ainda uma leve turbulência aleatória para que as partículas nunca parem completamente, dando uma sensação de “dança química contínua”, ideal para celular. Quer que eu faça isso?
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)