当前位置: 首页>>代码示例>>Python>>正文


Python Maze.makeMap方法代码示例

本文整理汇总了Python中maze.Maze.makeMap方法的典型用法代码示例。如果您正苦于以下问题:Python Maze.makeMap方法的具体用法?Python Maze.makeMap怎么用?Python Maze.makeMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maze.Maze的用法示例。


在下文中一共展示了Maze.makeMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Dungeon

# 需要导入模块: from maze import Maze [as 别名]
# 或者: from maze.Maze import makeMap [as 别名]
class Dungeon(Widget):
    def __init__(self, **kwargs):
        super(Dungeon, self).__init__(**kwargs)
        self.gameworld.init_gameworld(
            ['cymunk_physics', 'rotate_renderer', 'rotate', 'position',
             # 'cymunk_touch',
             'camera1'],
            callback=self.init_game)
        self.mazeobj = Maze()
        self.mazeobj.makeMap(50, 50, 100, 10, 30)
        self.maze = self.mazeobj.mapArr

    def init_game(self):
        self.setup_states()
        self.set_state()
        self.draw_some_stuff()

    def draw_some_stuff(self):
        gameview = self.gameworld.system_manager['camera1']
        # x, y = int(-gameview.camera_pos[0]), int(-gameview.camera_pos[1])
        # w, h = int(gameview.size[0] + x), int(gameview.size[1] + y)
        create_wall = self.create_wall
        for y in range(50):
            for x in range(50):
                if self.maze[y][x] in [1, 2]:
                    create_wall((50*x, 50*y))
        # gameview.focus_entity = True
        # gameview.entity_to_focus = None
        # self.mazeobj.printt()
        
    def create_wall(self, pos):
        x_vel = y_vel = 0
        angle = radians(0)
        angular_velocity = radians(0)
        shape_dict = {'width': 50, 'height': 50, 'mass': 1}
        col_shape = {'shape_type': 'box', 'elasticity': .5,
                     'collision_type': 1, 'shape_info': shape_dict,
                     'friction': 1.0}
        col_shapes = [col_shape]
        physics_component = {
            'main_shape': 'circle',
            'velocity': (x_vel, y_vel),
            'position': pos, 'angle': angle,
            'angular_velocity': angular_velocity,
            'vel_limit': 0,
            'ang_vel_limit': radians(0),
            'mass': 10, 'col_shapes': col_shapes}
        create_component_dict = {
            'cymunk_physics': physics_component,
            'rotate_renderer': {
                'texture': 'wall',
                'size': (50, 50),
                'render': True},
            'position': pos, 'rotate': 0, }
        component_order = [
            'position', 'rotate', 'rotate_renderer', 'cymunk_physics']
        return self.gameworld.init_entity(
            create_component_dict, component_order)

    def update(self, dt):
        self.gameworld.update(dt)

    def setup_states(self):
        self.gameworld.add_state(
            state_name='main',
            systems_added=['rotate_renderer'],
            systems_removed=[], systems_paused=[],
            systems_unpaused=['rotate_renderer'],
            screenmanager_screen='main')

    def set_state(self):
        self.gameworld.state = 'main'
开发者ID:dev-tacchinardi,项目名称:dungeon,代码行数:74,代码来源:main.py


注:本文中的maze.Maze.makeMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。