wip!: add scenes to the game

This commit is contained in:
Giovani Rodriguez
2021-07-07 14:49:04 -04:00
parent 27c49896bf
commit 91ebee74f2
6 changed files with 142 additions and 95 deletions

33
tetris/scene.py Normal file
View File

@@ -0,0 +1,33 @@
import pygame
from tetris.util import ConfigurationManager
from tetris.util import TextGenerator
from tetris.util import Controller
"""
TODO
"""
class TitleScene:
# Title screen options
ONE_PLAYER = "ONE_PLAYER"
TWO_PLAYER = "TWO_PLAYER"
def __init__(self) -> None:
image_path = ConfigurationManager.get("image", "title-screen")
self.splash_image = pygame.image.load(image_path)
self.cursor_position = None
self.cursor_flash_timer = 0
def draw(self, screen) -> None:
screen.fill(pygame.Color(ConfigurationManager.get("color", "window-bg")))
screen.blit(self.splash_image, (300, 0))
TextGenerator.draw("1 PLAYER", (300, 400), screen)
TextGenerator.draw("2 PLAYER", (300, 450), screen)
def update(self) -> None:
if Controller.key_pressed(pygame.K_DOWN):
self.current_option = TitleScene.ONE_PLAYER
if Controller.key_pressed(pygame.K_UP):
self.current_option = TitleScene.TWO_PLAYER