如何将PyGame键盘输入值存储在Varibale中
如何将PyGame键盘输入值存储在变量中。 在该地点pygame.k_r
我如何使用密钥变量分配给密钥输入。
import pygame
import random
from sys import exit
pygame.init()
screen = pygame.display.set_mode((300, 500))
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
**key = "r"**
key_input = pygame.key.get_pressed()
if key_input[pygame.**K_r**]:
pass
pygame.display.update()
clock.tick(60)
How do I store a pygame keyboard input value in a variable.
In the place pygame.K_r
how can I use my key variable to assign to the key input.
import pygame
import random
from sys import exit
pygame.init()
screen = pygame.display.set_mode((300, 500))
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
**key = "r"**
key_input = pygame.key.get_pressed()
if key_input[pygame.**K_r**]:
pass
pygame.display.update()
clock.tick(60)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将枚举器常数存储在变量中:
订阅的变量并从序列中获取状态:
Just store the enumerator constant in a variable:
and that variable for subscription and get status from sequence:
尝试一下,
Try it Out,