Like a Touch screen in the air... Like a mouse with a pencil.
Its very simple but very fun!
References
http://www.danilocesar.com/blog/2006/12/03/smartphones-aonde-podemos-parar
If you want to see this working:
http://www.youtube.com/watch?v=sjm_g9MSYPc
################################################################# # Developed by Danilo Cesar [http://www.danilocesar.com] # Inspired on: http://www.bigbold.com/snippets/posts/show/636 ################################################################# from appuifw import * from graphics import Image import camera, e32 app.body = c = Canvas() running = 1 def quit(): global running running = 0 app.exit_key_handler=quit app.title = u"O controle" app.screen = 'full' # or 'normal', 'large' def getdata(im, bpp=24): import struct, zlib im.save('D:\\pixels.png', bpp=bpp, compression='no') f = open('D:\\pixels.png', 'rb') f.seek(8 +8+13+4) chunk = [] while 1: n = struct.unpack('>L', f.read(4))[0] if n==0: break # 'IEND' chunk f.read(4) # 'IDAT' chunk.append(f.read(n)) f.read(4) # CRC f.close() return zlib.decompress(''.join(chunk)) # '\x00' prefix each line X = 80 Y = 60 while running: if X < 0: X = 0 if Y< 0: Y = 0 if X > 160 - 30: X = 160 - 30 if Y > 120 - 30: Y = 120-30 im = camera.take_photo('RGB', (160,120)) im.rectangle([(X,Y),(X+30,Y+30)], 0xff0000) # red outline # check hot spot whether active box = Image.new((30,30), 'L') # gray scale box.blit(im, (X,Y,X+30,Y+30)) data = getdata(box, 8) # check black for i in range(len(data)): if ord(data[i]) < 30 and ord(data[i]) > 0: X += i%31 - 15 Y += int(i/31) - 15 break c.blit(im, (0,0), (8,12)) # show camera