GD_Pygame/ui.py

44 lines
965 B
Python

#!/usr/bin/python3
class UI:
def __init__(self, app):
self.app = app
self.main_menu = MainMenu(app)
self.current_page = "main_menu"
def draw(self):
page = getattr(self, self.current_page)
page.draw()
def update(self):
page = getattr(self, self.current_page)
page.update()
class Page:
def __init__(self, app):
self.app = app
def draw(self):
pass
def update(self):
pass
class MainMenu(Page):
def draw(self):
self.app.screen.fill(self.app.blue)
w, h = self.app.screen.get_size()
x = 0
while x < w:
self.app.screen.blit(self.app.background_texture, (x, 0))
x += self.app.background_texture.get_width()
x = 0
while x < w:
self.app.screen.blit(self.app.floor_texture, (x, h - self.app.floor_texture.get_height()))
x += self.app.floor_texture.get_width()