Advertisement
phjoe

Test Meteor

Jan 9th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import appuifw as A
  2. import math
  3. import random
  4.  
  5. def stop():
  6.  global running
  7.  running=0
  8. A.app.screen='full'
  9.  
  10. running=1
  11. c=A.Canvas()
  12. A.app.body=c
  13. A.app.exit_key_handler=stop
  14.  
  15. cx=c.size[0]/2
  16. cy=c.size[1]/2
  17. dist=160
  18. PX=0
  19. PY=0
  20. PZ=200
  21. SZ=8
  22. rand=random.randrange
  23. V=[[rand(-40,40),rand(-40,40),rand(-40,40)]]
  24.  
  25. AX=AY=AZ=0
  26. while running:
  27.   sinx=math.sin(AX*math.pi/180)
  28.   cosx=math.cos(AX*math.pi/180)
  29.   siny=math.sin(AY*math.pi/180)
  30.   cosy=math.cos(AY*math.pi/180)
  31.   sinz=math.sin(AZ*math.pi/180)
  32.   cosz=math.cos(AZ*math.pi/180)
  33.   c.clear(0)
  34.   for n in range(len(V)):
  35.     ZX=V[n][0]*cosz - V[n][1]*sinz - V[n][0]
  36.     ZY=V[n][1]*sinz + V[n][1]*cosz - V[n][1]
  37.     YX=(V[n][0]+ZX)*cosy - V[n][2]*siny - (V[n][0]+ZX)
  38.     YZ=(V[n][0]+ZX)*siny + V[n][2]*cosy - V[n][2]
  39.     XY=(V[n][1]+ZY)*cosx - (V[n][2]+YZ)*sinx - (V[n][1]+ZY)
  40.     XZ=(V[n][1]+ZY)*sinx + (V[n][2]+YZ)*cosx - (V[n][2]+YZ)
  41.     z=(V[n][2]+PZ+(XZ+YZ))/dist
  42.     if z < 0.01:
  43.      z=0.01
  44.     x=(V[n][0]+PX+(YX+ZX))/z
  45.     y=(V[n][1]+PY+(ZY+XY))/z
  46.     c.point((cx+x,cy+y),0xdfdf00,width=SZ/z)
  47.   A.e32.ao_sleep(0.01)
  48.   PZ-=2
  49.   V.append([rand(-40,40),rand(-40,40),rand(-40,40)])
  50.   PZ%=160
  51.   if len(V)>25:
  52.    V.pop(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement