thread
This commit is contained in:
12
GameState.py
12
GameState.py
@@ -5,13 +5,15 @@ from lamps.Lamp import CREDIT
|
||||
from itertools import cycle
|
||||
from lamps.LampGroup import *
|
||||
import asyncio
|
||||
import threading
|
||||
|
||||
class GameState:
|
||||
players = None
|
||||
credits = config.BALLS_PER_GAME
|
||||
isPlaying = False
|
||||
isStarted = False
|
||||
isIdle = asyncio.Event()
|
||||
isIdle = True
|
||||
idleThread = None
|
||||
|
||||
def __init__(self, playerStateFactory, highscore, specialDisplay, currentPlayerID = 0):
|
||||
CREDIT.activate()
|
||||
@@ -45,13 +47,17 @@ class GameState:
|
||||
|
||||
def startIdleLoop(self):
|
||||
logging.info("Starting Idle Loop")
|
||||
asyncio.run(self.idleLoop())
|
||||
self.isIdle = True
|
||||
self.idleThread = threading.Thread(target=self.idleLoop)
|
||||
self.idleThread.start()
|
||||
pass
|
||||
|
||||
def stopIdleLoop(self):
|
||||
logging.info("Stopping Idle Loop")
|
||||
self.isIdle.set()
|
||||
self.isIdle = False
|
||||
self.idleThread.join()
|
||||
self.deactivate_all()
|
||||
|
||||
pass
|
||||
|
||||
def deactivate_all(self):
|
||||
|
||||
Reference in New Issue
Block a user