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


Python Keyboard.player_input方法代码示例

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


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

示例1: Levels

# 需要导入模块: from keyboard import Keyboard [as 别名]
# 或者: from keyboard.Keyboard import player_input [as 别名]

#.........这里部分代码省略.........
            elif x + 1 == coord[0] and y == coord[1]:
                self.coming = 'left'
            elif x - 1 == coord[0] and y == coord[1]:
                self.coming = 'right'
                
            if x == coord[0] and y == coord[1]:
                if self.coming == 'left':
                    x = x - 1
                if self.coming == 'right':
                    x = x + 1
                if self.coming == 'top':
                    y = y - 1
                if self.coming == 'bottom':
                    y = y + 1
                self.coming = ''
                self.talk = True
                self.cant_talk_box = Conversation(self.surface)
                    
        return x,y
    
    def Y1620(self,clock):
        #Setup objects
        self.layout = Map(self.surface)
        self.man = Character(self.surface)
        self.WilliamBradford = Character(self.surface)
        self.keyboard = Keyboard()
        self.settings = Settings(self.surface)
        self.inventory =  Inventory(self.surface)
        self.chat = Conversation(self.surface)
        self.mayflower = Mayflower(self.surface)
        
        self.x = 15
        self.y = 15
        self.direction = 'S'
        self.time = [0,0,100]
        self.go = False
        self.sun = -2
        self.firstSound = False
        pygame.mixer.music.load('data\\sound\\Godbless.mid')
        self.quit = 0
        while True:
            if self.sun > 8:
                pass #self.quit = self.layout.blackout(time)
            if self.sun < 0:
                self.layout.begin(time,'1620',self.sun)
            self.layout.sky(self.sun)
            self.x, self.y = self.stay_on_screen(self.x,self.y)
            self.layout.drawMap()
            self.x, self.y, self.go = self.man.move(self.x,self.y,self.direction,self.time,self.go)
            self.WilliamBradford.move(self.coords['WilliamBradford'][0],self.coords['WilliamBradford'][1],'S',self.time,False,1)
            self.WilliamBradford.check_for_chat(self.time, self.x, self.y, self.coords['WilliamBradford'][0], self.coords['WilliamBradford'][1])
            self.end, self.sound, self.pause, self.help = self.settings.settings_button()
            self.inventory.inventory_button()

            self.cant_talk(self.time)
            
            #Blit Mayflower
            self.mayflower.blit()
            
            if self.sun > 8:
                pass #self.quit = self.layout.blackout(time)
            if self.sun < 0:
                self.layout.begin(time, '1620',self.sun)

            if self.quit > 254:
                break
                
            for event in pygame.event.get():
                self.settings.settings_button(event)
                self.inventory.inventory_button(event)
                self.WilliamBradford.check_for_chat(self.time, self.x, self.y, self.coords['WilliamBradford'][0], self.coords['WilliamBradford'][1], event)
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == KEYDOWN:
                    self.go, self.direction = self.keyboard.player_input(event, self.go, self.direction)
                    if event.key == K_SPACE:
                        print self.x, self.y
            pygame.display.update()
            clock.tick()
        
            #Slow down movement
            if self.time[0] == 1:
                self.time[0] = 0
            if self.time[1] == 1:
                self.time[1] = 0
            if self.time[2] == 200:
                self.time[2] = 0
                self.sun += 1
            self.time[0] += 1
            self.time[1] += 1
            self.time[2] += 1
            if self.end:
                break
            if self.sound == False:
                pygame.mixer.music.stop()
                self.firstSound = False
            if self.sound == True and self.firstSound == False:
                pygame.mixer.music.play(-1, 0.0)
                self.firstSound = True
开发者ID:victormanakkat,项目名称:america,代码行数:104,代码来源:level.py


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