Browse Source

Possibly fixed detection of second player

master
klonfish 8 years ago committed by klonfish
parent
commit
8fe38ceb58
  1. 5
      gamemenu.py

5
gamemenu.py

@ -177,6 +177,7 @@ InputEvent = enum.Enum('InputEvent', ['UP', 'DOWN', 'LEFT',
class AbstractInput(): class AbstractInput():
def __init__(self): def __init__(self):
self.player_present = False
pass pass
def get_event(self): def get_event(self):
@ -203,6 +204,8 @@ class TestInput(AbstractInput):
pygame = self.__pygame pygame = self.__pygame
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.KEYDOWN: if event.type == pygame.KEYDOWN:
if self.control.get(event.key, None) == InputEvent.STEP_ON:
self.player_present = True
return self.controls.get(event.key, None) return self.controls.get(event.key, None)
return None return None
@ -370,7 +373,7 @@ if __name__ == '__main__':
while time.time() < start+wait_time: while time.time() < start+wait_time:
while True: while True:
evt = inp2.get_event() evt = inp2.get_event()
if evt == InputEvent.STEP_ON: if inp2.player_present:
inp1.running = False inp1.running = False
inp2.running = False inp2.running = False
start_game(game, 2) start_game(game, 2)

Loading…
Cancel
Save