Cleanup. /JL
Before Width: | Height: | Size: 1.6 MiB |
24
main.py
@@ -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
|
||||
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 165 KiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
BIN
resources/gfx/snake_banner.png
Normal file
After Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 377 KiB After Width: | Height: | Size: 377 KiB |
Before Width: | Height: | Size: 307 KiB After Width: | Height: | Size: 307 KiB |
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 300 KiB |
@@ -1,5 +1,11 @@
|
||||
import pygame
|
||||
|
||||
class StartScreen:
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
self.banner = pygame.image.load("resources/gfx/snake_banner.png")
|
||||
self.banner_width = int(self.parent.get_width())
|
||||
self.banner = pygame.transform.smoothscale(self.banner, (self.banner_width, int(self.banner_width*0.4)))
|
||||
|
||||
self.parent.screen.blit(self.banner, (0, 0))
|
||||
|