diff --git a/screenshots/2026-09-16-13-03.png b/screenshots/2026-09-16-13-03.png new file mode 100644 index 0000000..71fdc46 Binary files /dev/null and b/screenshots/2026-09-16-13-03.png differ diff --git a/src/controls.py b/src/controls.py index 027183c..f9d7462 100644 --- a/src/controls.py +++ b/src/controls.py @@ -12,6 +12,8 @@ controls = [ Control(arcade.key.S, "Le"), Control(arcade.key.A, "Bal"), Control(arcade.key.D, "Jobb"), + Control(arcade.key.ENTER, "Választ"), + Control(arcade.key.LSHIFT, "Vissza"), ] def key_press(key): diff --git a/src/gamestates/title.py b/src/gamestates/title.py index b79119b..76004b4 100644 --- a/src/gamestates/title.py +++ b/src/gamestates/title.py @@ -1,14 +1,25 @@ import arcade import assets import controls +import menu import text import renderers text = text.TextRenderer(6, 186, 210) panel = renderers.NineSlicesPanel(0,100,230,100) +m = [] + def switch(): - pass + global m + m = [ + menu.MenuItem("1", 100, 90, None, None, None, None, None, None), + menu.MenuItem("2", 100, 70 , None, None, None, None, None, None) + ] + + m[0].down = m[1] + m[1].up = m[0] + m[0].select() def update(dt): controltext = "" @@ -16,6 +27,8 @@ def update(dt): for c in controls.controls: controltext += f"{c.label}: {c.pressed}-{c.held}\n" + for i in m: + i.update() text.reset(controltext) text.type_all() @@ -24,6 +37,8 @@ def draw(game): arcade.LBWH(0, 0, game.screen_width, game.screen_height), arcade.color.RED, ) + for i in m: + i.render() panel.render() text.render() \ No newline at end of file diff --git a/src/menu.py b/src/menu.py new file mode 100644 index 0000000..5614846 --- /dev/null +++ b/src/menu.py @@ -0,0 +1,58 @@ +import arcade +import assets +import text +import controls + +# Választható menüelem több menüelem közt, ha nincs valamelyik irányba másik menüelem, az irányra None értéket adunk +class MenuItem: + def __init__(self, label, x, y, left, right, up, down, action, data=None): + self.left = left + self.right = right + self.up = up + self.down = down + self.action = action + self.data = data + self.x = x + self.y = y + self.text = text.TextRenderer(x, y) + self.selected = False + self.text.reset(label) + self.text.type_all() + + def select(self): + self.selected = True + + def update(self): + if not self.selected: + return + + if controls.is_control_pressed(4) and self.action: # Választ + self.action(self.data) + return + + if controls.is_control_pressed(0) and self.up: # Fel + self.selected = False + self.up.select() + + if controls.is_control_pressed(1) and self.down: # Le + self.selected = False + self.down.select() + + if controls.is_control_pressed(2) and self.left: # Bal + self.selected = False + self.left.select() + + if controls.is_control_pressed(3) and self.right: # Jobb + self.selected = False + self.right.select() + + + def render(self): + self.text.render() + + if self.selected: + arcade.draw_texture_rect( + assets.sprites["cursor"], + arcade.LBWH(self.x - 16, self.y - 6, 16, 16), + pixelated=True + ) \ No newline at end of file