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
- # kursor
- lebar,tinggi=40,40
- curx,cury=0,0
- posx,posy=0,0
- speed=2
- def handle():
- global curx,cury,posx,posy
- if kb.is_down(0x34): # 4 kiri
- curx-=speed
- if curx <0:
- curx=0
- posx+=speed
- if posx>0:
- posx=0
- elif kb.is_down(0x36): # 6 kanan
- curx+=speed
- if curx+lebar>W:
- curx=W-lebar
- posx-=speed
- if posx<-(gb.size[0]-W):
- posx=-(gb.size[0]-W)
- if kb.is_down(0x32): # 2 atas
- cury-=speed
- if cury <0:
- cury=0
- posy+=speed
- if posy>0:
- posy=0
- elif kb.is_down(0x38): # 8 bawah
- cury+=speed
- if cury+tinggi>H:
- cury=H-tinggi
- posy-=speed
- if posy<-(gb.size[1]-H):
- posy=-(gb.size[1]-H)
- while run:
- img.clear(0)
- img.blit(gb,target=(posx,posy))
- img.rectangle((curx,cury,curx+lebar,cury+tinggi),0xff0000)
- redraw(0)
- A.e32.ao_sleep(1e-04)
- handle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement