PyIgnition

https://github.com/animatinator/PyIgnition update for Python 3
Clone: git clone https://git.frombelow.net/PyIgnition.git
Log | Files | Refs | README

Wind.py (1128B)


      1 # Wind - randomised gravity
      2 
      3 import PyIgnition, pygame, sys
      4 
      5 
      6 screen = pygame.display.set_mode((800, 600))
      7 pygame.display.set_caption("PyIgnition demo: wind")
      8 clock = pygame.time.Clock()
      9 
     10 effect = PyIgnition.ParticleEffect(screen, (0, 0), (800, 600))
     11 source = effect.CreateSource((400, 600), initspeed = 5.0, initdirection = 0.0, initspeedrandrange = 2.0, initdirectionrandrange = 0.2, particlesperframe = 10, particlelife = 200, drawtype = PyIgnition.DRAWTYPE_POINT, colour = (255, 255, 200))
     12 grav = effect.CreateDirectedGravity(0.0, 0.2, [1, 0])
     13 #othergrav = effect.CreateDirectedGravity(0.05, 0.0, [0, 1])
     14 circle = effect.CreateCircle((0, 0), (0, 0, 0), bounce = 0.4, radius = 30.0)
     15 
     16 
     17 while True:
     18 	for event in pygame.event.get():
     19 		if event.type == pygame.QUIT:
     20 			sys.exit()
     21 			
     22 		elif event.type == pygame.KEYDOWN:
     23 			if event.key == pygame.K_s:
     24 				effect.SaveToFile("Test.xml")
     25 	
     26 	screen.fill((100, 125, 200))
     27 	circle.SetPos(pygame.mouse.get_pos())
     28 	if circle.curframe % 30 == 0:
     29 		circle.ConsolidateKeyframes()
     30 	effect.Update()
     31 	effect.Redraw()
     32 	pygame.display.update()
     33 	clock.tick(30)