Código
from tkinter import *
tk= Tk()
tk.title("Juego RPG")
c= Canvas(tk, width=400, height=400)
tk.geometry(newGeometry="400x400")
fondo = PhotoImage(file='fondo.gif')
c.create_image(0,0,anchor=NW, image=fondo)
posx=120
posy=120
c.place(x=0,y=0)
arriba = PhotoImage(file='arriba.gif')
abajo = PhotoImage(file='abajo.gif')
img_arr= c.create_image(posx,posy,image=arriba)
cuantas= 0
def moverPersonaje(event):
global posx
global posy
global img_arr
global img_aba
global cuantas
if event.keysym == 'Up':
posx=posx
posy-=5
if cuantas !=0:
c.delete(img_aba)
c.delete(img_arr)
img_arr= c.create_image(posx,posy,image=arriba)
elif event.keysym == 'Down':
posx = posx
posy += 5
if cuantas == 0:
c.delete(img_arr)
img_aba=c.create_image(posx,posy,image=abajo)
cuantas+=1
else:
c.delete(img_arr)
c.delete(img_aba)
img_aba=c.create_image(posx,posy,image=abajo)
c.update()
c.bind_all('<Up>',moverPersonaje)
c.bind_all('<Down>',moverPersonaje)
c.bind_all('<Left>',moverPersonaje)
c.bind_all('<Right>',moverPersonaje)
tk.mainloop()


 
  




 Autor
 Autor
		



 En línea
									En línea
								


