Browse Source

Added a main menu which will load the editor. If escape is pressed in the editor, use will be returned to the main menu.

master
Bryan Miller 6 years ago
parent
commit
574e32a954
5 changed files with 31 additions and 4 deletions
  1. +3
    -3
      game/__init__.py
  2. +2
    -1
      game/nodes.py
  3. +1
    -0
      game/scenes/__init__.py
  4. +25
    -0
      game/scenes/mainmenu.py
  5. BIN
      graphics/MainMenu_Logo.png

+ 3
- 3
game/__init__.py View File

@@ -60,9 +60,9 @@ def start():
#text.set_color(255, 64, 128)
#text.position_y = 30

e = scenes.editor.get()
sm.register_node(e)
sm.activate_node(e.name)
sm.register_node(scenes.mainmenu.get())
sm.register_node(scenes.editor.get())
sm.activate_node("MAIN_MENU")

_RUNNING = True
while _RUNNING:

+ 2
- 1
game/nodes.py View File

@@ -734,7 +734,8 @@ class NodeMapEditor(gbe.nodes.Node2D):
return

if data["key_name"] == "escape":
self.emit("QUIT")
self.emit("SCENECHANGE", {"scene":"MAIN_MENU", "hold":False})
#self.emit("QUIT")
if data["key_name"] == "tab":
p.toggle_render_mode()
elif data["key_name"] == "w":

+ 1
- 0
game/scenes/__init__.py View File

@@ -1 +1,2 @@
from . import editor
from . import mainmenu

+ 25
- 0
game/scenes/mainmenu.py View File

@@ -0,0 +1,25 @@

from .. import gbe
from ..nodes import *

_TREE = None
def get():
global _TREE
if _TREE is None:
root = gbe.nodes.NodeSurface("MAIN_MENU")
root.scale_to_display = True
root.keep_aspect_ratio = True
root.align_center = True
root.set_surface((64, 64))
root.set_clear_color((0,0,0,0))

menu = NodeOptions("Options", root)
#menu.add_option("IttyBitty.ttf", 4, "Game", "SCENECHANGE", {"scene":"Game", "hold":False})
menu.add_option("IttyBitty.ttf", 4, "Editor", "SCENECHANGE", {"scene":"Editor", "hold":False})
menu.add_option("IttyBitty.ttf", 4, "Quit", "QUIT")
menu.position = (10, 14)

overlay = gbe.nodes.NodeSprite("Overlay", root)
overlay.image = "MainMenu_Logo.png"
_TREE = root
return _TREE

BIN
graphics/MainMenu_Logo.png View File

Before After
Width: 64  |  Height: 64  |  Size: 936B

Loading…
Cancel
Save