Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # s60_sparkler
- from random import randrange as rnd, random, choice
- from appuifw import *
- from graphics import *
- import e32,audio,os,sys,key_codes,time,math,sensor,sysinfo
- # R G B
- WHITE = (255, 255, 255)
- GRAY = (185, 185, 185)
- BLACK = ( 0, 0, 0)
- RED = (155, 0, 0)
- GREEN = ( 0, 155, 0)
- BLUE = ( 0, 0, 155)
- PURPLE = (128, 0, 128)
- YELLOW = (255, 255, 0)
- ORANGE = (255, 128, 0)
- bg=GREEN
- flare=YELLOW
- def quit():
- global run
- run=0
- def draw(rect):
- try: canvas.blit(img)
- except: pass
- img=None
- app.screen='large'
- app.orientation='portrait'
- app.directional_pad=False
- x,y=sysinfo.display_pixels()
- img=Image.new((x,y))
- app.body=canvas=Canvas(redraw_callback=draw)
- app.exit_key_handler=quit
- Total_x, Total_y=canvas.size
- def cv(): pass
- cv.x,cv.y = x/2,y/2
- def up_event(event):
- pass
- def dn_event(event):
- cv.x,cv.y=event[0],event[1]-20
- def mv_event(event):
- cv.x,cv.y=event[0],event[1]-20
- canvas.bind(key_codes.EButton1Up, up_event, ((0,0), (Total_x,Total_y)))
- canvas.bind(key_codes.EButton1Down, dn_event, ((0,0), (Total_x,Total_y)))
- canvas.bind(key_codes.EDrag, mv_event, ((0,0), (Total_x,Total_y)))
- sprites,obj=100,[]
- def mv():
- return rnd(0,12)*choice([1,-1])
- def cycle():
- return [cv.x,cv.y,mv(),mv(),0.5+(random()*5),rnd(20,50)]
- run=1
- while run:
- if len(obj) < sprites: obj.append(cycle())
- img.clear(bg)
- for i in range(len(obj)):
- if obj[i][-1] < 0: obj[i]=cycle()
- obj[i][ 0] += obj[i][ 2]
- obj[i][ 1] += obj[i][ 3]
- obj[i][-1] -= obj[i][-2]
- img.point((int(obj[i][0]),int(obj[i][1])),flare,width=int(obj[i][-1]))
- img.text((30,60),u'Swipe The Screen', fill=WHITE,font=(u'Nokia Hindi S60',40,STYLE_BOLD))
- draw(())
- e32.ao_sleep(0.02)
- #
- '''
- e32.ao_yield() # bottom of _running_loop_
- app_lock.wait()
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement