Addiing individual controller support. /JL

This commit is contained in:
2025-04-13 12:55:39 +02:00
parent 724123e569
commit c99c9945cf
15 changed files with 1159 additions and 78 deletions

27
main.py
View File

@@ -3,6 +3,16 @@ import time
import controls
from screens.startscreen import StartScreen
from tilemap.playground import PlayGround
from player.player import Player, Players
from enum import Enum
class State(Enum):
STARTING = 1
PLAYING = 2
PAUSING = 3
ENDING = 4
SETTING = 5
HIGHSCORE = 6
class Snake:
def __init__(self):
@@ -15,7 +25,7 @@ class Snake:
self.windowed: bool = True
self.width: int = 800
self.height: int =600
self.startscreen = None
self.screen = None
self.icon = pygame.image.load("snake.webp")
pygame.display.set_icon(self.icon)
@@ -29,7 +39,20 @@ class Snake:
while self.running:
match self.state:
case 0:
self.startscreen = StartScreen(self)
self.screen = StartScreen(self)
pygame.display.flip()
waiting = True
while waiting:
for event in pygame.event.get():
if event.type == pygame.QUIT:
waiting = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_F1:
print("F1 pressed!")
waiting = False
elif event.key == pygame.K_F2:
print("F2 pressed!")
waiting = False
case 1:
pass
case 2: