Setup for basic Editor for map, started gameplay screen

This commit is contained in:
2026-05-20 15:58:06 +02:00
parent cc0a92060b
commit 6283fb0d5a
13 changed files with 383 additions and 59 deletions
+23
View File
@@ -0,0 +1,23 @@
class BaseScreen:
def __init__(self, game):
self.game = game
self.elements = []
def process_event(self, event):
pass
def update(self, dt):
pass
def draw(self, surface):
pass
def show(self):
for element in self.elements:
element.show()
def hide(self):
for element in self.elements:
element.hide()
+35
View File
@@ -0,0 +1,35 @@
from game.screens.base_screen import BaseScreen
import pygame as pg
import pygame_gui as pgi
class GamePlay(BaseScreen):
def __init__(self, game):
super().__init__(game)
self.tile_multiplicator = 2.0
self.width, self.height = pg.display.get_surface().get_size()
self.map_screen = pg.surface.Surface((int(self.width/4*3),int(self.height/6*5)))
self.scroll = [0, 0]
self.map = 'test'
self.path = 'assets/maps/' + str(self.map) + '.json'
try:
self.game.tilemap.load(self.path)
except FileNotFoundError:
print('File not Found')
def process_event(self, event):
pass
def update(self, dt):
pass
def draw(self, surface):
self.map_screen.fill((40, 40, 40))
render_scroll = (int(self.scroll[0]), int(self.scroll[1]))
self.game.tilemap.render(self.map_screen, offset=render_scroll)
self.game.window.blit(self.map_screen, (0, self.height/6))
+79
View File
@@ -0,0 +1,79 @@
from game.screens.base_screen import BaseScreen
import pygame as pg
import pygame_gui as pgi
class MainMenu(BaseScreen):
def __init__(self, game):
super().__init__(game)
manager = game.ui_manager
width, height = pg.display.get_surface().get_size()
# Größen
title_width = 400
title_height = 80
button_width = 250
button_height = 60
center_x = width // 2
self.title = pgi.elements.UILabel(
relative_rect=pg.Rect(
center_x - title_width // 2,
int(height * 0.2),
title_width,
title_height
),
text="MAIN MENU",
manager=manager
)
self.play_button = pgi.elements.UIButton(
relative_rect=pg.Rect(
center_x - button_width // 2,
int(height * 0.35),
button_width,
button_height
),
text="Play",
manager=manager
)
self.quit_button = pgi.elements.UIButton(
relative_rect=pg.Rect(
center_x - button_width // 2,
int(height * 0.60),
button_width,
button_height
),
text="Quit",
manager=manager
)
self.elements = [
self.title,
self.play_button,
self.quit_button
]
def process_event(self, event):
if event.type == pgi.UI_BUTTON_PRESSED:
if event.ui_element == self.play_button:
# Zum Gameplay wechseln
self.game.change_screen("game")
if event.ui_element == self.quit_button:
pg.quit()
exit()