Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import appuifw as A
- import graphics as G
- import keyboard
- run=1
- kb=keyboard.Keyboard()
- W,H=G.sysinfo.display_pixels()
- img=G.Image.new((W,H))
- gb=G.Image.open(u'e:\\Fotonya.jpg') # edit
- def stop():
- global run;run=0
- def redraw(x):
- if img:c.blit(img)
- A.app.screen='full'
- c = A.Canvas(redraw_callback=redraw,event_callback=kb.handle_event)
- A.app.body=c
- A.app.exit_key_handler=stop
- cx,cy=W/2,H/2
- x,y=0,0
- # kotak ditengah
- lebar, tinggi=60,40
- def handle():
- global x,y
- step=2
- if kb.is_down(0x34):
- x-=step
- if x <-(gb.size[0]-((W/2)+lebar)):
- x=-(gb.size[0]-((W/2)+lebar))
- elif kb.is_down(0x36):
- x+=step
- if x >(W/2)-lebar:
- x=(W/2)-lebar
- elif kb.is_down(0x32):
- y-=step
- if y <-(gb.size[1]-((H/2)+tinggi)):
- y=-(gb.size[1]-((H/2)+tinggi))
- elif kb.is_down(0x38):
- y+=step
- if y >(H/2)-tinggi:
- y=(H/2)-tinggi
- while run:
- img.clear(0)
- img.blit(gb,target=(x,y))
- img.rectangle((cx-lebar,cy-tinggi,cx+lebar,cy+tinggi),0xff0000)
- redraw(0)
- A.e32.ao_sleep(1e-04)
- handle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement