Cleanup. /JL

This commit is contained in:
2025-03-22 22:27:38 +01:00
parent c3de5def6e
commit 4df2e82365
24 changed files with 31 additions and 3 deletions

24
main.py
View File

@@ -1,10 +1,12 @@
import pygame
import time
import controls
from screens.startscreen import StartScreen
from tilemap.playground import PlayGround
class Snake:
def __init__(self):
self.STATES = {"starting": 0, "playing": 1, "pausing": 2, "ending": 3, "setting": 4, "highscore": 5}
self.running = True
self.numplayers: int = 1
self.playground: PlayGround = None
@@ -13,9 +15,11 @@ class Snake:
self.windowed: bool = True
self.width: int = 800
self.height: int =600
self.startscreen = None
self.icon = pygame.image.load("snake.webp")
pygame.display.set_icon(self.icon)
self.set_state("starting")
self.set_windowed(self.width, self.height)
# self.set_fullscreen(self.width, self.height)
@@ -23,12 +27,27 @@ class Snake:
def mainloop(self):
while self.running:
self.screen.fill((100, 200, 200))
match self.state:
case 0:
self.startscreen = StartScreen(self)
case 1:
pass
case 2:
pass
case 3:
pass
case 4:
pass
case 5:
pass
pygame.display.flip()
time.sleep(5)
self.running = False
pygame.quit()
def set_state(self, state: str) -> None:
self.state = self.STATES[state]
def set_windowed(self, width:int, height: int) -> None:
self.screen = pygame.display.set_mode((width, height))
self.windowed = True
@@ -38,6 +57,9 @@ class Snake:
self.screen = pygame.display.set_mode((width, height), flags=pygame.FULLSCREEN)
self.windowed = False
def get_width(self) -> int:
return self.width
@property
def numplayers(self) -> int:
return self._numplayers