Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # py60snowfall.py
- import e32,audio,appuifw,os,sys,key_codes,time,math,random,graphics,sensor
- import sysinfo
- yscr=sysinfo.display_pixels()[1]
- xscr=sysinfo.display_pixels()[0]
- nflakes=240
- imgSnow=8
- WHITE=0xffffff
- LBLUE=0x000080
- moveX=range(nflakes)
- moveY=range(nflakes)
- XX=range(nflakes)
- YY=range(nflakes)
- for i in range(nflakes):
- moveY[i]=random.randint(5,20)
- dir=random.choice([-1,1])
- moveX[i]=dir*random.randint(1,3)
- XX[i]=random.randint(0,xscr)
- YY[i]=random.randint(0,yscr)
- def falling():
- global moveX,moveY,XX,YY
- img.clear(LBLUE)
- for i in range(nflakes):
- dir=random.choice([-1,1])
- moveX[i]=dir*moveX[i]
- XX[i]=XX[i]+moveX[i]
- YY[i]=YY[i]+moveY[i]
- if((XX[i]>xscr)or(XX[i]<0)):
- moveX[i]=-moveX[i]
- if(YY[i]>yscr):
- moveY[i]=random.randint(1,24)
- dir=random.choice([-1,1])
- moveX[i]=dir*random.randint(1,3)
- XX[i]=random.randint(0,xscr)
- YY[i]=dir*random.randint(1,24)
- img.ellipse([(XX[i],YY[i]),(XX[i]+imgSnow,YY[i]+imgSnow)],WHITE,fill=WHITE)
- canvas.blit(img,(0,0))
- timer.after(0.1,falling)
- draw(())
- def draw(rect):
- try:
- canvas.blit(img)
- except:pass
- appuifw.e32.reset_inactivity()
- def exit(pos):
- app_lock.signal()
- img=graphics.Image.new((xscr,yscr))
- appuifw.app.directional_pad=False
- canvas=appuifw.Canvas(redraw_callback=draw)
- appuifw.app.body=canvas
- canvas.bind(key_codes.EButton1Down,exit)
- appuifw.app.screen='full'
- timer=appuifw.e32.Ao_timer()
- appuifw.app.orientation='portrait'
- falling()
- e32.ao_yield()
- app_lock=appuifw.e32.Ao_lock()
- app_lock.wait()
- timer.cancel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement