Browse Source

Game menu refreshes periodically to prevent other clients from painting

master
klonfish 8 years ago committed by klonfish
parent
commit
1e4c9fc4df
  1. 9
      gamemenu.py

9
gamemenu.py

@ -204,7 +204,7 @@ 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: if self.controls.get(event.key, None) == InputEvent.STEP_ON:
self.player_present = True self.player_present = True
return self.controls.get(event.key, None) return self.controls.get(event.key, None)
return None return None
@ -342,12 +342,17 @@ if __name__ == '__main__':
games = Game.__subclasses__() games = Game.__subclasses__()
game_idx = 0 game_idx = 0
old_idx = -1 old_idx = -1
lastrefresh = 0
while True: while True:
if old_idx != game_idx: if old_idx != game_idx:
gamecls = games[game_idx] gamecls = games[game_idx]
game = gamecls() game = gamecls()
out.sendFrame(create_menu_frame(dim, game))
old_idx = game_idx old_idx = game_idx
lastrefresh = 0
if time.time() >= lastrefresh+1:
out.sendFrame(create_menu_frame(dim, game))
lastrefresh = time.time()
evt = inp1.get_event() evt = inp1.get_event()
if evt == InputEvent.LEFT: if evt == InputEvent.LEFT:

Loading…
Cancel
Save