Bubbles!.py (1258B)
1 # Bubbles! 2 3 import PyIgnition, pygame, sys, math 4 5 6 screen = pygame.display.set_mode((800, 600)) 7 pygame.display.set_caption("PyIgnition demo: bubbles") 8 clock = pygame.time.Clock() 9 10 effect = PyIgnition.ParticleEffect(screen, (0, 0), (800, 600)) 11 source = effect.CreateSource(initspeed = 1.0, initdirection = 0.0, initspeedrandrange = 0.5, initdirectionrandrange = math.pi, particlelife = 1000, colour = (200, 255, 200), drawtype = PyIgnition.DRAWTYPE_BUBBLE, radius = 4.0) 12 source.CreateParticleKeyframe(500, colour = (250, 100, 250)) 13 source.CreateParticleKeyframe(75, colour = (190, 190, 200)) 14 source.CreateParticleKeyframe(100, colour = (50, 250, 252)) 15 source.CreateParticleKeyframe(125, colour = (250, 250, 255)) 16 effect.CreateDirectedGravity(strength = 0.04, direction = [0, -1]) 17 18 19 while True: 20 for event in pygame.event.get(): 21 if event.type == pygame.QUIT: 22 sys.exit() 23 24 elif event.type == pygame.MOUSEBUTTONDOWN: 25 source.CreateKeyframe(source.curframe + 1, pos = pygame.mouse.get_pos(), particlesperframe = 1) 26 source.CreateKeyframe(source.curframe + 2, pos = pygame.mouse.get_pos(), particlesperframe = 0) 27 28 screen.fill((100, 150, 255)) 29 effect.Update() 30 effect.Redraw() 31 pygame.display.update() 32 clock.tick(30)