Advertisement
phjoe

simg

Jan 28th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import appuifw as A
  2. import graphics as G
  3. import keyboard
  4.  
  5. run=1
  6. kb=keyboard.Keyboard()
  7. W,H=G.sysinfo.display_pixels()
  8. img=G.Image.new((W,H))
  9.  
  10. gb=G.Image.open(u'e:\\Fotonya.jpg') # edit
  11.  
  12. def stop():
  13.  global run;run=0
  14.  
  15. def redraw(x):
  16.  if img:c.blit(img)
  17.  
  18. A.app.screen='full'
  19. c = A.Canvas(redraw_callback=redraw,event_callback=kb.handle_event)
  20. A.app.body=c
  21. A.app.exit_key_handler=stop
  22.  
  23. cx,cy=W/2,H/2
  24. x,y=0,0
  25.  
  26. # kotak ditengah
  27. lebar, tinggi=60,40
  28.  
  29. def handle():
  30.  global x,y
  31.  step=2
  32.  if kb.is_down(0x34):
  33.   x-=step
  34.   if x <-(gb.size[0]-((W/2)+lebar)):
  35.    x=-(gb.size[0]-((W/2)+lebar))
  36.  elif kb.is_down(0x36):
  37.   x+=step
  38.   if x >(W/2)-lebar:
  39.    x=(W/2)-lebar
  40.  
  41.  elif kb.is_down(0x32):
  42.   y-=step
  43.   if y <-(gb.size[1]-((H/2)+tinggi)):
  44.    y=-(gb.size[1]-((H/2)+tinggi))
  45.  elif kb.is_down(0x38):
  46.   y+=step
  47.   if y >(H/2)-tinggi:
  48.    y=(H/2)-tinggi
  49.  
  50. while run:
  51.  img.clear(0)
  52.  img.blit(gb,target=(x,y))
  53.  img.rectangle((cx-lebar,cy-tinggi,cx+lebar,cy+tinggi),0xff0000)
  54.  redraw(0)
  55.  A.e32.ao_sleep(1e-04)
  56.  handle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement