Finding Positions on the Screen in Pygame

Sometimes when making a pygame game you’ll want to place objects on the screen.  Trial and error is one way to do it, but if you have a bunch of things to place, for instance if you’re making a maze or setting up a room, trial and error will take a long time.  The code here will let you click anywhere on the screen, and see the location of where you clicked.  The location will appear in the Shell, so it won’t actually change your game.   The code you’re adding starts at the red arrow (the rest is already there from the tutorial project, at the top of the game loop.)

Finding the mouse position