I was making a simple game in pygame, and I realized that I needed a bunch of markers, graphs and all kinds of global employees. So I decided to define the class and use it as follows:
class Staff():
def __init__(self):
self.modes={'menu':True,'spawning':False,'sprite_change':False}
self.timer=pygame.time.Clock()
self.tick_count=0
and in my game loop, I just pass one variable to all my functions:
def main_loop():
staff=Staff()
while not done:
update_positions(staff)
clear_background(staff)
draw_sprites(staff)
I know that this method works and is quite convenient (for me), but I wonder how it will affect the speed of my game, maybe I'm doing something terrible? Thank you very much for your reply.
source
share