Advertisement
here2share

# absorb_effect.py

Jul 19th, 2017
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # absorb_effect.py aka particle_charge
  2.  
  3. import appuifw,graphics,e32,sysinfo,random
  4. def quit():
  5.     global run
  6.     run=0
  7.  
  8. def draw(rect):
  9.     try: canvas.blit(img)
  10.     except: pass
  11.  
  12. img=None
  13. appuifw.app.screen='large'
  14. appuifw.app.orientation='portrait'
  15. appuifw.app.directional_pad=False
  16. xy=sysinfo.display_pixels()
  17. img=graphics.Image.new(xy)
  18. appuifw.app.body=canvas=appuifw.Canvas(redraw_callback=draw)
  19. appuifw.app.exit_key_handler=quit
  20.  
  21. xy=xy[0],xy[1]-90
  22. x,y=xy[0]/2,xy[1]/2
  23. sprites,timer,reset,obj=100,10,5,[]
  24. target=[x,y]
  25.  
  26. flare=20.0/y
  27.  
  28. def moving(pos,target,spd):
  29.     mov=0
  30.     if pos+spd <= target:mov=spd
  31.     if pos-spd >= target:mov=-spd
  32.     return mov
  33.  
  34. def cycle():
  35.     return ([random.randrange(xy[0]),random.randrange(xy[1]),1])
  36.  
  37. run=1
  38. while run:
  39.     if len(obj)<sprites:obj.append(cycle())
  40.     img.clear(0)
  41.     for i in range(len(obj)):
  42.         if obj[i][0] == x or obj[i][1] == y or obj[i][2] > 8+random.randrange(12):
  43.             obj[i]=cycle()
  44.         obj[i][0]+=moving(obj[i][0],target[0],1)
  45.         obj[i][1]+=moving(obj[i][1],target[1],1)
  46.         obj[i][2]+=flare
  47.         img.point((obj[i][0],obj[i][1]),0xdadada,width=int(obj[i][2]))
  48.     draw(())
  49.     e32.ao_sleep(0.02)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement