2024-02-27 19:42:19 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
class UI:
|
2024-02-27 20:12:13 +01:00
|
|
|
def __init__(self, app):
|
|
|
|
self.app = app
|
|
|
|
|
|
|
|
self.main_menu = MainMenu(app)
|
|
|
|
|
2024-02-27 19:42:19 +01:00
|
|
|
self.current_page = "main_menu"
|
|
|
|
|
2024-02-27 20:12:13 +01:00
|
|
|
def draw(self):
|
|
|
|
page = getattr(self, self.current_page)
|
|
|
|
page.draw()
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
page = getattr(self, self.current_page)
|
|
|
|
page.update()
|
2024-02-27 19:42:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Page:
|
2024-02-27 20:12:13 +01:00
|
|
|
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)
|
2024-02-27 20:35:45 +01:00
|
|
|
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()
|