I would like to know how to capture more than one key being pressed at the same time?

Asked

Viewed 27 times

0

In case I’m wanting to make both paddle move at the same time.

import turtle
# Function
def paddle_a_up():
    y = paddle_a.ycor()
    y += 20
    paddle_a.sety(y)

def paddle_a_down():
    y = paddle_a.ycor()
    y -= 20
    paddle_a.sety(y)

def paddle_b_up():
    y = paddle_b.ycor()
    y += 20
    paddle_b.sety(y)

def paddle_b_down():
    y = paddle_b.ycor()
    y -= 20
    paddle_b.sety(y) 
# Keyboard binding   
wn.listen()
wn.onkeypress(paddle_a_up, "w")
wn.onkeypress(paddle_a_down, "s")
wn.onkeypress(paddle_b_up, "Up")
wn.onkeypress(paddle_b_down, "Down")

Imagem mostrando o jogo
click on the image to view it in its original size

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.