Browse Source

Added an 'official' map that will be 'walked' during the main menu.

master
Bryan Miller 6 years ago
parent
commit
caa9daa387
3 changed files with 2861 additions and 3 deletions
  1. +2820
    -0
      data/maps/main
  2. +34
    -3
      game/nodes.py
  3. +7
    -0
      game/scenes/mainmenu.py

+ 2820
- 0
data/maps/main
File diff suppressed because it is too large
View File


+ 34
- 3
game/nodes.py View File

import random
from . import gbe from . import gbe
import pygame import pygame


elif self._orientation == "w": elif self._orientation == "w":
x -= 1 x -= 1
self.move_to(x, y) self.move_to(x, y)
return True
return False


def move_backward(self, ignore_passible=False): def move_backward(self, ignore_passible=False):
orient = self._orientation orient = self._orientation
self._orientation = "w" self._orientation = "w"
elif self._orientation == "w": elif self._orientation == "w":
self._orientation = "e" self._orientation = "e"
self.move_forward(ignore_passible)
res = self.move_forward(ignore_passible)
self._orientation = orient self._orientation = orient
return res


def is_passible(self, x, y, d): def is_passible(self, x, y, d):
""" """
Returns true if it's possible to move forward from the x, y map position in the direction given. Returns true if it's possible to move forward from the x, y map position in the direction given.
d - 0 = North, 1 = East, 2 = South, 3 = West
""" """
d = self._d_s2n(d)
if self._currentLayer == "" or d < 0 or d >= 4: if self._currentLayer == "" or d < 0 or d >= 4:
return False return False
layer = self._layer[self._currentLayer] layer = self._layer[self._currentLayer]






class NodeMapWalker(gbe.nodes.Node):
def __init__(self, name="MapWalker", parent=None):
try:
gbe.nodes.Node.__init__(self, name, parent)
except NodeError as e:
raise e
self._delta = 0

def on_update(self, dt):
p = self.parent
if p is None or not isinstance(p, NodeGameMap):
return
#print("PING")
self._delta += dt
if self._delta > 1000:
self._delta %= 1000
if not p.move_forward():
r = random.randint(0,1)
if r == 0:
p.turn_left()
elif r == 1:
p.turn_right()









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

root.set_surface((64, 64)) root.set_surface((64, 64))
root.set_clear_color((0,0,0,0)) root.set_clear_color((0,0,0,0))


gmap = NodeGameMap("gm", root)
gmap.set_resources("environment.json", "walls.json")
gmap.set_render_mode(1)
gmap.load_map("main", False)

mwalker = NodeMapWalker("MapWalker", gmap)

menu = NodeOptions("Options", root) menu = NodeOptions("Options", root)
#menu.add_option("IttyBitty.ttf", 4, "Game", "SCENECHANGE", {"scene":"Game", "hold":False}) #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, "Editor", "SCENECHANGE", {"scene":"Editor", "hold":False})

Loading…
Cancel
Save