Chapter 6.6 - Moving the Stick Figure

6.6 - Moving the Stick Figure

Download the code for the Stick Figure from here and open it to Thonny.

We will use the mouse to move the Stick Figure.

Uncomment lines 52 to 55 to read the position of the mouse. 

Run the code and you should see the position of the mouse printed in Shell.

Change lines 65 to 79 to add movement to the drawings.

# Draw stick figure # Head pygame.draw.circle(screen, BLACK, [100 + x, 100 + y], 15) # Body pygame.draw.line(screen, ORANGE, [100 + x, 115 + y], [100 + x , 180 + y], 5) # Legs pygame.draw.line(screen, BLUE, [100 + x , 180 + y ], [80 + x, 250 + y], 5) pygame.draw.line(screen, BLUE, [100 + x, 180 + y], [120 + x, 250 + y], 5) # Arms pygame.draw.line(screen, RED, [100 + x, 125 + y], [50 + x, 140 + y], 5) pygame.draw.line(screen, RED, [100 + x, 125 + y], [150 + x, 140 + y], 5)


Don't forget to check the indentation.

You can download the code from here to test it