一方向はpygame.key.get_pressed()
です。例 -
keys = pygame.keys.get_pressed()
if keys[pygame.K_w] and keys[pygame.K_SPACE]:
print(1)
EDIT:これは私がそれを実装する方法です -
#!/usr/bin/python3
import pygame
from pygame.locals import *
from sys import exit
#initializing variables
pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Key Press Test")
f1=pygame.font.SysFont("comicsansms",24)
#main loop which displays the pressed keys on the screen
while True:
for i in pygame.event.get():
a=100
screen.fill((255,255,255))
if pygame.key.get_focused():
press=pygame.key.get_pressed()
# checking if they are pressed at the same time or not.
if press[pygame.K_w] and press[pygame.K_SPACE]:
print (1)
for i in xrange(0,len(press)):
if press[i]==1:
name=pygame.key.name(i)
text=f1.render(name,True,(0,0,0))
screen.blit(text,(100,a))
a=a+100
pygame.display.update()
これはまだ動作しません:( – Noobcoder
あなたの実装方法を教えてください。 –