feat!: add title screen scene
This commit is contained in:
68
tetri5/scene.py
Normal file
68
tetri5/scene.py
Normal file
@@ -0,0 +1,68 @@
|
||||
import pygame
|
||||
from tetri5.util import ConfigurationManager
|
||||
from tetri5.util import TextGenerator
|
||||
from tetri5.util import Controller
|
||||
|
||||
"""
|
||||
TODO
|
||||
"""
|
||||
class TitleScene:
|
||||
|
||||
# Title screen options
|
||||
ONE_PLAYER = "1 PLAYER"
|
||||
TWO_PLAYER = "2 PLAYER"
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._tile_size = ConfigurationManager.get("engine", "tile-size")
|
||||
self._logo_image = pygame.image.load(ConfigurationManager.get("image", "title-screen"))
|
||||
self._cursor_position_one = ConfigurationManager.get("position", "cursor-option-one")
|
||||
self._cursor_position_two = ConfigurationManager.get("position", "cursor-option-two")
|
||||
self._cursor_position = self._cursor_position_one
|
||||
self._cursor_blink_interval = ConfigurationManager.get("engine", "cursor-blink-interval")
|
||||
self._cursor_blink_time = 0
|
||||
self._cursor_color = pygame.Color(ConfigurationManager.get("color", "cursor"))
|
||||
self._cursor_off = False
|
||||
self._background_color = pygame.Color(ConfigurationManager.get("color", "window-bg"))
|
||||
self._logo_position = ConfigurationManager.get("position", "title-logo")
|
||||
self._option_one_position = ConfigurationManager.get("position", "option-one")
|
||||
self._option_two_position = ConfigurationManager.get("position", "option-two")
|
||||
self._is_multiplayer = False
|
||||
|
||||
def draw(self, surface: pygame.Surface) -> None:
|
||||
surface.fill(self._background_color)
|
||||
surface.blit(self._logo_image, self._logo_position)
|
||||
|
||||
TextGenerator.draw(TitleScene.ONE_PLAYER, self._option_one_position, surface)
|
||||
TextGenerator.draw(TitleScene.TWO_PLAYER, self._option_two_position, surface)
|
||||
|
||||
if self._cursor_off:
|
||||
pygame.draw.circle(surface, self._cursor_color, self._cursor_position, self._tile_size // 3)
|
||||
|
||||
def update(self, elapsed_time) -> None:
|
||||
if Controller.key_pressed(pygame.K_UP):
|
||||
self._cursor_position = self._cursor_position_one
|
||||
self._is_multiplayer = False
|
||||
if Controller.key_pressed(pygame.K_DOWN):
|
||||
self._cursor_position = self._cursor_position_two
|
||||
self._is_multiplayer = True
|
||||
|
||||
self._cursor_blink_time += elapsed_time
|
||||
if self._cursor_blink_time >= self._cursor_blink_interval:
|
||||
self._cursor_blink_time = 0
|
||||
self._cursor_off = not self._cursor_off
|
||||
|
||||
"""
|
||||
TODO
|
||||
"""
|
||||
class SinglePlayerScene:
|
||||
pass
|
||||
|
||||
"""
|
||||
TODO
|
||||
"""
|
||||
class MultiPlayerScene:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user