Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def showGui(x,y,max_x,max_y):
- if y >= max_y or x >= max_x:
- print('Error, beyound the screen')
- # strar line creation
- str = ''
- for i in range(max_x):
- str += '*'
- # boundary line creation
- str1 ='*'
- for i in range(max_x-2):
- str1+=' '
- str1+='*'
- # boundary line + avater creation
- # *space#space*
- avater='*'
- for i in range(x-2):
- avater+=' '
- avater+='#'
- for i in range(max_x-x-1):
- avater+=' '
- avater+='*'
- print(str) # first star line
- for i in range(y-2):
- print(str1)
- print(avater)
- for i in range(max_y-y-1):
- print(str1)
- print(str) # last star line
- #showGui end here
- # Main program start here
- max_x=40
- max_y=20
- x = 3
- y = 3
- ans = ''
- showGui(x,y,max_x,max_y)
- while ans!='q':
- ans = input()
- if ans == 'q':
- exit()
- elif ans == 'a':
- x-=1
- if x < 2:
- x = 2
- elif ans == 'd':
- x+=1
- if x > max_x-1:
- x = max_x-1
- elif ans == 'w':
- y-=1
- if y < 2:
- y = 2
- elif ans == 's':
- y+=1
- if y > max_y-1:
- y = max_y-1
- showGui(x,y,max_x,max_y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement