Add input manager.

This commit is contained in:
paulusja 2026-04-16 15:06:56 +02:00
parent 6186b2b40f
commit 8c07acc22f
2 changed files with 15 additions and 5 deletions

10
snake/input_manager.py Normal file
View 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

View File

@ -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()