# Scroll Simple # (C)2006 MARCOS OCHOA DIEZ import appuifw from graphics import * import e32, miso, thread from key_codes import * import math, time import audio from random import randint def lighton(): while wanadoo: miso.reset_inactivity_time() e32.ao_sleep(5) def tiempo(n): HOR=n/3600 MIN=(n /60)%60 SEG= n % 60 return (str(HOR)+":"+str(MIN)+":"+str(SEG)) def _raw_input( txt ): return appuifw.query( unicode( txt ), "text" ) appuifw.app.title=u"^MvIiIaX^ Scroll" appuifw.note(u"Bienvenid@ Al Programa ^MvIiIaX^ Scroll Programado Por Marcos Ochoa Diez.", "info" ) e32.ao_sleep(8) a1=int( _raw_input(u"¿ Horas Para Que Todo Comienze ? ") ) a2=int( _raw_input(u"¿ Minutos Para Que Todo Comienze ? ") ) a3=int( _raw_input(u"¿ Segundos Para Que Todo Comienze ? ") ) esperatotal=(a1*3600)+(a2*60)+a3 megan=1 luzquieres=int( _raw_input("Luz Pantalla Siempre Encencida 1-SI 2-NO: ") ) coloresale=int( _raw_input("Colores Aleatorios 1-SI 2-NO: ") ) rojoama=int( _raw_input("Color De Letras 1-Rojo 2-Amarillo 3-Azul 4-Verde: ") ) if luzquieres==1: encender=int( _raw_input("0 Encendida Ya X Segundos Esperar Para Encender: ") ) durantecuan=int( _raw_input("Durante Cuantos Minutos Mantenemos La Luz Encendida: ") ) durantecuan=(durantecuan*60)-13 if luzquieres==1 and encender>0: sonidito=int( _raw_input("Reproducir Sonido 1-SI 2-NO A Modo De Alarma: ") ) else: sonidito=2 if sonidito==1: sonicuan= _raw_input(u"Cuantas Veces Hacemos Sonar El Sonido: ") quesoni= _raw_input(u"Sonido Debe Estar En e:\sounds\digital: ") antiro='e:\\sounds\\digital\\'+str(quesoni) msg=appuifw.query(u'Introduce Un Mensaje', 'text',u'marcos y maria son los mejores y se quieren mogollon').upper() class Keyboard(object): def __init__(self,onevent=lambda:None): self._keyboard_state={} self._downs={} self._onevent=onevent def handle_event(self,event): if event['type'] == appuifw.EEventKeyDown: code=event['scancode'] if not self.is_down(code): self._downs[code]=self._downs.get(code,0)+1 self._keyboard_state[code]=1 elif event['type'] == appuifw.EEventKeyUp: self._keyboard_state[event['scancode']]=0 self._onevent() def is_down(self,scancode): return self._keyboard_state.get(scancode,0) def pressed(self,scancode): if self._downs.get(scancode,0): self._downs[scancode]-=1 return True return False keyboard=Keyboard() appuifw.app.screen='full' font = [] font += [0x83, 0xED, 0xEE, 0xED, 0x83, 0xff] font += [0xBE, 0x80, 0xB6, 0xB6, 0xC9, 0xff] font += [0xC1, 0xBE, 0xBE, 0xBE, 0xDD, 0xff] font += [0xBE, 0x80, 0xBE, 0xBE, 0xC1, 0xff] font += [0x80, 0xB6, 0xB6, 0xB6, 0xBE, 0xff] font += [0x80, 0xF6, 0xF6, 0xF6, 0xFE, 0xff] font += [0xC1, 0xBE, 0xBE, 0xB6, 0x86, 0xff] font += [0x80, 0xF7, 0xF7, 0xF7, 0x80, 0xff] font += [0xff, 0xbE, 0x80, 0xBe, 0xff, 0xff] font += [0xdF, 0xBf, 0xBf, 0xBf, 0xC0, 0xff] font += [0x80, 0xf7, 0xeB, 0xDD, 0xbE, 0xff] font += [0x80, 0xbF, 0xbF, 0xbF, 0xbF, 0xff] font += [0x80, 0xfD, 0xf3, 0xfD, 0x80, 0xff] font += [0x80, 0xfB, 0xf7, 0xeF, 0x80, 0xff] font += [0xc1, 0xbE, 0xbE, 0xbE, 0xc1, 0xff] font += [0x80, 0xf6, 0xf6, 0xf6, 0xf9, 0xff] font += [0xc1, 0xbE, 0xaE, 0xdE, 0xa1, 0xff] font += [0x80, 0xf6, 0xe6, 0xd6, 0xb9, 0xff] font += [0xd9, 0xb6, 0xb6, 0xb6, 0xcD, 0xff] font += [0xfE, 0xfE, 0x80, 0xfE, 0xfE, 0xff] font += [0xc0, 0xbF, 0xbF, 0xbF, 0xc0, 0xff] font += [0xf8, 0xe7, 0x9F, 0xe7, 0xf8, 0xff] font += [0xc0, 0xbF, 0xc7, 0xbF, 0xc0, 0xff] font += [0x9C, 0xeB, 0xf7, 0xeB, 0x9c, 0xff] font += [0xfC, 0xfB, 0x87, 0xfB, 0xfC, 0xff] font += [0x9E, 0xaE, 0xb6, 0xbA, 0xbC, 0xff] running=1 def quit(): global running running=0 appuifw.app.exit_key_handler=quit blobsize=10 fx = 1 fd = 1 il = 0 global loco loco=0 pontox=0 lerole=time.time() while megan: e32.ao_yield() rest=time.time()-lerole e32.ao_sleep(1) pontox=esperatotal-rest print tiempo(int(pontox))+" Queda Para Empezar...\n" if rest>=esperatotal: megan=0 img=Image.new((176,208)) canvas=appuifw.Canvas(event_callback=keyboard.handle_event) appuifw.app.body=canvas import time start_time=time.clock() n_frames=0 delay = 0 canvas.clear(0) y = 0 x = 0 lechonpraderoso=0 start_t = time.time() if luzquieres==1 and encender==0: wanadoo=1 loco=1 comienz=time.time() thread.start_new_thread(lighton, ()) while running: restita=time.time()-start_t if luzquieres==1 and restita==encender: wanadoo=1 loco=1 comienz=time.time() thread.start_new_thread(lighton, ()) if sonidito==1: if lechonpraderoso==0: from audio import * vengaasonar = Sound.open(antiro) vengaasonar.play(int(sonicuan)) lechonpraderoso=1 if loco==1: lurele=time.time()-comienz if durantecuan==lurele: wanadoo=0 running=0 c = ord(msg[(il/6)]) if c == 32: r = 0xff else: r = font[(c-65)*6 + (il%6)] il += 1 if il>=len(msg)*6: il = 0 x = (176-(7*blobsize))/2 p = 1 for j in range(0,7): if ((r & p) == 0): if coloresale==1: rojoama=randint(1,20) if rojoama==1: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xff0000) if rojoama==2: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xffff00) if rojoama==3: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0x0000ff) if rojoama==4: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0x00ff00) if rojoama==5: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xff00ff) if rojoama==6: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0x453366) if rojoama==7: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xff66f3) if rojoama==8: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xf7f9f4) if rojoama==9: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0x811234) if rojoama==10: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xddffdd) if rojoama==11: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xa34b32) if rojoama==12: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xffab74) if rojoama==13: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0x112233) if rojoama==14: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0x238374) if rojoama==15: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xaabbcc) if rojoama==16: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xa3b4c5) if rojoama==17: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xc56c3d) if rojoama==18: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xfa567d) if rojoama==19: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xff66ff) if rojoama==20: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0xff66ff) else: canvas.rectangle((x,y,x+blobsize,y+blobsize), fill = 0x000000) p = p * 2 x = x + blobsize img = screenshot() e32.ao_yield() e32.ao_sleep(delay) canvas.blit(img,target=(0,blobsize)) if keyboard.is_down(EScancodeLeftArrow): canvas.rectangle((0,0,176,blobsize), fill = 0x000000) blobsize -= 1 if blobsize<1: blobsize = 1 if keyboard.is_down(EScancodeRightArrow): canvas.rectangle((0,0,176,blobsize), fill = 0x0000) blobsize += 1 if keyboard.is_down(EScancodeDownArrow): delay += .01 if keyboard.is_down(EScancodeUpArrow): delay -= .01 if delay<0: delay = 0 if keyboard.pressed(EScancodeHash): filename=u'd:\\m8axscroll.png' canvas.text((0,32),u'Grabando ScreenShot A D:',fill=0xffff00) canvas.text((0,48),filename,fill=0xffff00) img.save(filename) n_frames+=1 end_time=time.clock() total=end_time-start_time restita=time.time()-start_t print "MvIiIaX 2006\n" print "Tiempo Transcurrido. "+tiempo(int(restita))+"\n" print "%d frames\n %f segundos\n %f FPS\n %f ms/frame.\n"%(n_frames,total, n_frames/total, total/n_frames*1000.)