Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Simple Walking Simulation
- def display_position(x, y):
- print(f"Current Position: ({x}, {y})")
- def main():
- print("Welcome to the Walking Simulator!")
- print("Use W (up), A (left), S (down), D (right) to move. Type 'quit' to exit.")
- # Starting position
- x, y = 0, 0
- display_position(x, y)
- while True:
- # Get user input
- move = input("Move (W/A/S/D): ").lower()
- if move == "w":
- y += 1
- elif move == "a":
- x -= 1
- elif move == "s":
- y -= 1
- elif move == "d":
- x += 1
- elif move == "quit":
- print("Exiting Walking Simulator. Goodbye!")
- break
- else:
- print("Invalid input! Use W, A, S, D to move or 'quit' to exit.")
- continue
- # Display new position
- display_position(x, y)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment