"""Programa para que cuando caminemos por carreteras por la noche los coches nos vean. Nos colocamos el movil donde queramos y el hara lucecitas para que nos vean... Cursor Arriba Aumenta Velocidad De Luces, Cursor Abajo La Reduce... Programa creado Por M8AX""" import appuifw from graphics import * import e32, thread, miso from key_codes import * 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" ) def quit(): global lucia lucia=0 wanadoo=0 appuifw.app.exit_key_handler=quit 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.title=u"^MvIiIaX^ Paseo Carretera" wanadoo=1 appuifw.note(u"Bienvenid@ Al Programa ^MvIiIaX^ Paseo Carretera Programado Por Marcos Ochoa Diez.", "info" ) appuifw.app.screen='full' canvas=appuifw.Canvas(event_callback=keyboard.handle_event) appuifw.app.body=canvas canvas.clear(0) thread.start_new_thread(lighton, ()) lucia=1 suma=0 lulu=0 frufru=0 delay=0.2 while lucia: e32.ao_yield() e32.ao_sleep(delay) suma+=delay lulu+=1 frufru=randint(1,2) if keyboard.is_down(EScancodeDownArrow): delay += .1 if keyboard.is_down(EScancodeUpArrow): delay -= .1 if delay<0: delay = 0 if lulu %10<>0: if lulu %2==0: if frufru==1: canvas.rectangle((0,0,176,208), fill = 0xff0000) else: canvas.rectangle((0,0,176,208), fill = 0x0000ff) else: if frufru==1: canvas.rectangle((0,0,176,208), fill = 0xffff00) else: canvas.rectangle((0,0,176,208), fill = 0x00ff00) else: if frufru==1: canvas.rectangle((0,0,176,208), fill = 0xffffff) else: canvas.rectangle((0,0,176,208), fill = 0x001122) print "\nTmp. De Programa. "+tiempo(int(suma)) print "\n^MvIiIaX^ Corp. 2006"