Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Move your character
- #functions
- #---------------------------------
- def printField(x,y):
- countY = 0;
- while countY <= 10:
- countX = 0;
- while countX <= 10:
- if countX == x and countY == y:
- print("x", end=' ');
- else:
- print("#", end=' ');
- countX = countX + 1;
- print()
- countY = countY + 1;
- def clearScreen():
- count = 0
- while count < 21:
- print();
- count = count + 1;
- #---------------------------------
- #Main
- #yfield 0-10
- #xfield 0-10
- x = 5;
- y = 5;
- printField(x,y);
- while x >= 0 and x <= 10 and y >= 0 and y <= 10:
- print("Insert a command");
- command = input("(up, down, left or right): ");
- # adds enough empty lines to clear the screan
- clearScreen();
- #changes the coordinates of the x
- if command == "up":
- y = y - 1;
- elif command == "down":
- y = y + 1;
- elif command == "left":
- x = x - 1;
- elif command == "right":
- x = x + 1;
- else:
- print("Insert a valid command");
- printField(x,y);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement