Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14011

How to bind several key presses together in turtle graphics?

$
0
0

I'm trying to make a connect-the-dot python game. I want the game to register 2 button presses. Example: if the user presses Up and Right arrow key, the turtle goes 45 degrees north east.

here is my code:

import turtleflynn=turtle.Turtle()win=turtle.Screen()win.bgcolor("LightBlue")flynn.pensize(7)flynn.pencolor("lightBlue")win.listen()def Up():    flynn.setheading(90)    flynn.forward(25)def Down():    flynn.setheading(270)    flynn.forward(20)def Left():    flynn.setheading(180)    flynn.forward(20)def Right():    flynn.setheading(0)    flynn.forward(20)def upright():    flynn.setheading(45)    flynn.forward(20)win.onkey(Up, "Up")win.onkey(Down,"Down")win.onkey(Left,"Left")win.onkey(Right,"Right")

Viewing all articles
Browse latest Browse all 14011

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>