kjdsa
This commit is contained in:
20
GameState.py
20
GameState.py
@@ -11,7 +11,7 @@ class GameState:
|
|||||||
credits = config.BALLS_PER_GAME
|
credits = config.BALLS_PER_GAME
|
||||||
isPlaying = False
|
isPlaying = False
|
||||||
isStarted = False
|
isStarted = False
|
||||||
isIdle = True
|
isIdle = asyncio.Event()
|
||||||
|
|
||||||
def __init__(self, playerStateFactory, highscore, specialDisplay, currentPlayerID = 0):
|
def __init__(self, playerStateFactory, highscore, specialDisplay, currentPlayerID = 0):
|
||||||
CREDIT.activate()
|
CREDIT.activate()
|
||||||
@@ -48,7 +48,7 @@ class GameState:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def stopIdleLoop(self):
|
def stopIdleLoop(self):
|
||||||
self.isIdle = False
|
self.isIdle.set()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def idleLoop(self):
|
async def idleLoop(self):
|
||||||
@@ -56,12 +56,16 @@ class GameState:
|
|||||||
UPPER_PLAYFIELD_TIME_LAMPS, TUNNEL_NUMBER_LAMPS,
|
UPPER_PLAYFIELD_TIME_LAMPS, TUNNEL_NUMBER_LAMPS,
|
||||||
TUNNEL_LAMPS, TUNNEL_SCORE_LAMPS]
|
TUNNEL_LAMPS, TUNNEL_SCORE_LAMPS]
|
||||||
while True:
|
while True:
|
||||||
for lamps in all_cabinet_lamps:
|
#for lamps in all_cabinet_lamps:
|
||||||
for _ in lamps.lamps:
|
#for _ in lamps.lamps:
|
||||||
lamps.cycle()
|
#lamps.cycle()
|
||||||
if not self.isIdle:
|
#if not self.isIdle:
|
||||||
return
|
# return
|
||||||
time.sleep(0.1)
|
#time.sleep(0.1)
|
||||||
|
random_group = random.choice(all_cabinet_lamps)
|
||||||
|
random_group.toggleRandom(0.2)
|
||||||
|
if self.isIdle.is_set():
|
||||||
|
return
|
||||||
|
|
||||||
def createPlayers(self, playerCount):
|
def createPlayers(self, playerCount):
|
||||||
players = []
|
players = []
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from lamps.Lamp import Lamp
|
from lamps.Lamp import Lamp
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
class LampGroup:
|
class LampGroup:
|
||||||
@@ -39,6 +40,11 @@ class LampGroup:
|
|||||||
|
|
||||||
self.currentLampPtr -= 1
|
self.currentLampPtr -= 1
|
||||||
|
|
||||||
|
def toggleRandom(self, sleepTime):
|
||||||
|
random_lamp = random.choice(self.lamps)
|
||||||
|
random_lamp.activate()
|
||||||
|
time.sleep(sleepTime)
|
||||||
|
random_lamp.deactivate()
|
||||||
def cycle(self):
|
def cycle(self):
|
||||||
if self.currentLamp:
|
if self.currentLamp:
|
||||||
self.currentLamp.deactivate()
|
self.currentLamp.deactivate()
|
||||||
|
|||||||
Reference in New Issue
Block a user