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


Python Dungeon.create_item方法代码示例

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


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

示例1: main

# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import create_item [as 别名]
def main(stdscr):

    curses.curs_set(0)
    curses.start_color()
    curses.initscr()

    # Create windows for log (lines 1-3), map (lines 4-20) and stats (lines 21-24).
    log_window = curses.newwin(3, 79, 0, 1)
    map_window = curses.newwin(17, 79, 3, 1)
    stat_window = curses.newwin(4, 79, 20, 1)

    dungeon = Dungeon()
    
    dungeon.create_item(7, 9, "ring")
    dungeon.create_item(10, 12, "ring")
    dungeon.create_item(20, 10, "potion")
    
    player = Player()
    
    state = Basic(stdscr, log_window, map_window, stat_window, dungeon, player)
    new_state = None
        
    while 1:
        
        window_size = stdscr.getmaxyx()
        
        # Check if the terminal size is botched - refactor when you understand curses better
         
        if  window_size[0] < 24 or window_size[1] < 80:
            state = create_state("termresize", stdscr, log_window, map_window, stat_window, dungeon, player)
            state.draw()
            curses.doupdate()
            c = stdscr.getch()
        
        else:
        
            # Cargoculted on Monday morning, 05:00.
            # Not doing this initscr() will result in a black screen before first keypress when moving
            # to a new state. No idea what causes this. Will do for now.
            if new_state is not None:
                curses.initscr()

            state.draw()
            curses.doupdate()
        
            c = stdscr.getch()
        
            new_state = state.handle_input(c)
       
            if new_state is not None:
                if new_state == "quit" :
                    break
                else:
                    state = create_state(new_state, stdscr, log_window, map_window, stat_window, dungeon, player)
                    stdscr.erase()
开发者ID:Lasokki,项目名称:roguelike,代码行数:57,代码来源:roguelike.py


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