My code is like this:
import pygame
from multiprocessing import Process, Queue
#dosomething
#dosomething
def keyboard():
keys_pressed = q.get()
if key_pressed[pygame.K_a]:
#dosomething
q = Queue()
keyboard_process = Process(target=keyboard)
keyboard_process.start()
while True:
q.put(pygame.key.get_pressed())
#dosomething
keyboard_process.join()
#dosomething
But, the value of "q" is always [0, 0, ……, 0] even if I press "A"."keyboard_process.join()" always does nothing.So the game doesn't work.
How can a process get the current value of a global variable in python? Please help me.