Skip to content

Add settings, new game, and quit options to the main menu #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rpg/views/loading_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from rpg.views.game_view import GameView
from rpg.views.inventory_view import InventoryView
from rpg.views.main_menu_view import MainMenuView
from rpg.views.settings_view import SettingsView


class LoadingView(arcade.View):
Expand Down Expand Up @@ -56,5 +57,7 @@ def on_update(self, delta_time: float):
self.window.views["inventory"].setup()
self.window.views["main_menu"] = MainMenuView()
self.window.views["main_menu"].setup()
self.window.views["settings"] = SettingsView()
self.window.views["settings"].setup()

self.window.show_view(self.window.views["game"])
55 changes: 55 additions & 0 deletions rpg/views/main_menu_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,54 @@ def on_draw(self):
width=self.window.width,
)

arcade.draw_text(
"Settings (Y)",
self.window.width / 2,
self.window.height - 150,
arcade.color.AMAZON,
32,
anchor_x="center",
anchor_y="center",
align="center",
width=self.window.width,
)

arcade.draw_text(
"Close Game (Q)",
self.window.width / 2,
self.window.height - 250,
arcade.color.AMAZON,
32,
anchor_x="center",
anchor_y="center",
align="center",
width=self.window.width,
)

arcade.draw_text(
"Resume Game (ESC)",
self.window.width / 2,
self.window.height - 350,
arcade.color.AMAZON,
32,
anchor_x="center",
anchor_y="center",
align="center",
width=self.window.width,
)

arcade.draw_text(
"New Game (N)",
self.window.width / 2,
self.window.height - 450,
arcade.color.AMAZON,
32,
anchor_x="center",
anchor_y="center",
align="center",
width=self.window.width,
)

def setup(self):
pass

Expand All @@ -34,3 +82,10 @@ def on_show_view(self):
def on_key_press(self, symbol: int, modifiers: int):
if symbol == arcade.key.ESCAPE:
self.window.show_view(self.window.views["game"])
elif symbol == arcade.key.Y:
self.window.show_view(self.window.views["settings"])
elif symbol == arcade.key.Q:
self.window.close()
elif symbol == arcade.key.N:
self.window.views["game"].setup()
self.window.show_view(self.window.views["game"])
37 changes: 37 additions & 0 deletions rpg/views/settings_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
Settings
"""
import arcade
import rpg.constants as constants


class SettingsView(arcade.View):
def __init__(self):
super().__init__()
self.started = False
arcade.set_background_color(arcade.color.ALMOND)

def on_draw(self):
arcade.start_render()
arcade.draw_text(
"Settings",
self.window.width / 2,
self.window.height - 50,
arcade.color.ALLOY_ORANGE,
44,
anchor_x="center",
anchor_y="center",
align="center",
width=self.window.width,
)

def setup(self):
pass

def on_show_view(self):
arcade.set_background_color(arcade.color.ALMOND)
arcade.set_viewport(0, self.window.width, 0, self.window.height)

def on_key_press(self, symbol: int, modifiers: int):
if symbol == arcade.key.ESCAPE:
self.window.show_view(self.window.views["main_menu"])