What I'm trying to do is define controls for a certain thing in another module which defines everything else for that thing, then run the controls from the main loop via a function.
The problem with trying to call it with a function, from what I've tried, is that the events that the function sees only match the events when the function was defined at the program start instead of the current events; meaning, no events.
Here's an example of what I mean:
main file
from pygameinitmodule import *
import othermodule
#event_list = pygame.event.get() is run in pygameinitmodule to define it for all modules
running = True
while running:
#updating the event_list
event_list = pygame.event.get()
if certaingamestate:
othermodule.controlFunction()
othermodule
from pygameinitmodule import *
def controlFunction():
global event_list
for event in event_list:
# controls here
And if I am then to run the code, the controls don't work. But if I put the exact same code from the function into the main loop it works fine. Is there another way I'm supposed to do something like this, or am I doing it mostly right while overlooking one critical part?
Edit: to the person that marked this as a duplicate, it's not. The question you marked this as a duplicate of is focusing on a different thing.