コード例 #1
0
ファイル: conftest.py プロジェクト: brashnyom/mossbread
def sample_game_map(sample_tiles):
    return GameMap.from_file(get_relative_path("fixtures/map.csv"),
                             sample_tiles)
コード例 #2
0
import pyglet
import yaml

from pyglet.window import key

from rendering import Tileset, Rendering
from game_map import GameMap
from entities import Character, NPC, EntityHandler

tile_data_file = pyglet.resource.file("assets/tiles.yml")
tile_data = yaml.safe_load(tile_data_file)
tile_data_file.close()

tileset = Tileset("assets/sample_tileset.png", tile_data)
game_map = GameMap.from_file("assets/courtyard.csv", tile_data)
rendering = Rendering(tileset)
entity_handler = EntityHandler(game_map)

player = entity_handler.spawn_entity(Character, 1, 1, 6)
npc = entity_handler.spawn_entity(NPC, 47, 2, 6)

rendering.add_entity(player)
rendering.add_entity(npc)

npc.set_path(game_map, 9, 3)


@rendering.window.event
def on_key_press(symbol, modifiers):
    if symbol == key.W:
        entity_handler.move_entity(player.id, 0, 1)