Add input manager.
This commit is contained in:
parent
6186b2b40f
commit
8c07acc22f
10
snake/input_manager.py
Normal file
10
snake/input_manager.py
Normal file
@ -0,0 +1,10 @@
|
||||
import pygame
|
||||
|
||||
|
||||
class InputManager:
|
||||
QUIT = 0
|
||||
|
||||
def process_input(self):
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
return InputManager.QUIT
|
||||
@ -1,19 +1,19 @@
|
||||
import pygame
|
||||
from window import Window
|
||||
from input_manager import InputManager
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
window = Window(title='Snake', size=(800, 600), background_color=(0, 128, 0))
|
||||
input_manager = InputManager()
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
framerate = 25
|
||||
|
||||
shall_abort = False
|
||||
last_input = None
|
||||
|
||||
while not shall_abort:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
shall_abort = True
|
||||
while last_input != InputManager.QUIT:
|
||||
last_input = input_manager.process_input()
|
||||
|
||||
window.reset()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user