Python pygame 模块,K_h() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用pygame.K_h()

项目:pyDino    作者:lucaspbordignon    | 项目源码 | 文件源码
def run(self):
        # Setup
        for event in pygame.event.get():
            if (event.type == pygame.QUIT):
                return (False, '', None)
            if (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_UP and not self.dino.is_jumping()):
                    self.dino.set_movement(8)
                    self.dino.set_jumping(True)
                if (event.key == pygame.K_DOWN):
                    self.dino.set_movement(-5)
                if (event.key == pygame.K_h):
                    if self.dino.get_coins() > 4:
                        self.dino.set_coins(self.dino.get_coins() - 5)
                        self.powers.append(power(self.dino.get_position()))

        # Movement
        self.move_all_objects()

        # Enemies
        if (self.enemy.check_hitted(self.dino) and not self.enemy.get_hitted()):
            del self.enemy
            self.enemy = enemy(self.screen_size, self.ground_limit)
            self.dino.set_lives(1, type='decrement')
            if (not self.dino.get_lives()):
                return(True, 'game_over', None)

        # Prize
        self.check_prize_hitted()

        # Objects to show
        objects_to_show = {}
        objects_to_show['lives'] = self.dino.get_lives()
        objects_to_show['coins'] = self.dino.get_coins()
        objects_to_show['power'] = self.powers
        objects_to_show['char'] = self.dino
        objects_to_show['enemy'] = self.enemy
        objects_to_show['prize'] = self.prize
        self.clock.tick(self.difficulty * 60)
        return (True, 'match_running', objects_to_show)
项目:SerialGraphicator    作者:newtonis    | 项目源码 | 文件源码
def Refresh(self,screen):
        self.UpdateChangeScale() #check if user clicked to change scale
        self.CalcGraph()
        total_surface = pygame.surface.Surface((self.widthTotal,self.height))
        total_surface.blit( self.GetGraphSurface() , (0,0))
        total_surface.blit( self.GetListSurface () , (self.widthA,0))
        #self.BlitMaxMin( total_surface )
        screen.blit(total_surface,(self.x,self.y))
        for x in range(len(self.variables)):
            self.reference[self.variables[x]].show_item.UpdatePosition()
            self.reference[self.variables[x]].show_item.Refresh(screen)
        for x in range(len(self.variables)):
            if not self.reference[ self.variables[x] ].GetEnabled():
                continue
            if self.playing:
                last_value = self.reference[ self.variables[x] ].last_value
            else:
                last_value = self.reference[self.variables[x]].hold_value
            surface = pygame.surface.Surface((40,20))
            surface.fill((255,255,255))
            AddBorder(surface)
            textValue = fonts.adamCG[str(15)].render( GetValueName( last_value ),1,(0,0,0))
            BlitInCenter(surface,textValue)
            #print self.GetRelPos(x)
            screen.blit(surface , (self.x + self.widthA - 20 , self.y + self.GetRelPos(x) - 5 ))
        self.holdSelector.Refresh(screen)
        if self.holdSelector.GetSelected() == "Release":
            self.Release()
        elif self.holdSelector.GetSelected() == "Hold":
            self.Hold()

        if pygame.key.get_pressed()[pygame.K_h]:
            self.Hold()

        if pygame.key.get_pressed()[pygame.K_r]:
            self.Release()

        if self.drawMark:
            screen.blit(self.drawMark,(self.x + self.drawMarkX,self.y + self.drawMarkY))
项目:SerialGraphicator    作者:newtonis    | 项目源码 | 文件源码
def Refresh(self,screen):
        self.UpdateChangeScale() #check if user clicked to change scale
        self.CalcGraph()
        total_surface = pygame.surface.Surface((self.widthTotal,self.height))
        total_surface.blit( self.GetGraphSurface() , (0,0))
        total_surface.blit( self.GetListSurface () , (self.widthA,0))
        #self.BlitMaxMin( total_surface )
        screen.blit(total_surface,(self.x,self.y))
        for x in range(len(self.variables)):
            self.reference[self.variables[x]].show_item.UpdatePosition()
            self.reference[self.variables[x]].show_item.Refresh(screen)
        for x in range(len(self.variables)):
            if not self.reference[ self.variables[x] ].GetEnabled():
                continue
            if self.playing:
                last_value = self.reference[ self.variables[x] ].last_value
            else:
                last_value = self.reference[self.variables[x]].hold_value
            surface = pygame.surface.Surface((40,20))
            surface.fill((255,255,255))
            AddBorder(surface)
            textValue = fonts.adamCG[str(15)].render( GetValueName( last_value ),1,(0,0,0))
            BlitInCenter(surface,textValue)
            #print self.GetRelPos(x)
            screen.blit(surface , (self.x + self.widthA - 20 , self.y + self.GetRelPos(x) - 5 ))
        self.holdSelector.Refresh(screen)
        if self.holdSelector.GetSelected() == "Release":
            self.Release()
        elif self.holdSelector.GetSelected() == "Hold":
            self.Hold()

        if pygame.key.get_pressed()[pygame.K_h]:
            self.Hold()

        if pygame.key.get_pressed()[pygame.K_r]:
            self.Release()

        if self.drawMark:
            screen.blit(self.drawMark,(self.x + self.drawMarkX,self.y + self.drawMarkY))
项目:SerialGraphicator    作者:newtonis    | 项目源码 | 文件源码
def Refresh(self,screen):
        self.UpdateChangeScale() #check if user clicked to change scale
        self.CalcGraph()
        total_surface = pygame.surface.Surface((self.widthTotal,self.height))
        total_surface.blit( self.GetGraphSurface() , (0,0))
        total_surface.blit( self.GetListSurface () , (self.widthA,0))
        #self.BlitMaxMin( total_surface )
        screen.blit(total_surface,(self.x,self.y))
        for x in range(len(self.variables)):
            self.reference[self.variables[x]].show_item.UpdatePosition()
            self.reference[self.variables[x]].show_item.Refresh(screen)
        for x in range(len(self.variables)):
            if not self.reference[ self.variables[x] ].GetEnabled():
                continue
            if self.playing:
                last_value = self.reference[ self.variables[x] ].last_value
            else:
                last_value = self.reference[self.variables[x]].hold_value
            surface = pygame.surface.Surface((40,20))
            surface.fill((255,255,255))
            AddBorder(surface)
            textValue = fonts.adamCG[str(15)].render( GetValueName( last_value ),1,(0,0,0))
            BlitInCenter(surface,textValue)
            #print self.GetRelPos(x)
            screen.blit(surface , (self.x + self.widthA - 20 , self.y + self.GetRelPos(x) - 5 ))
        self.holdSelector.Refresh(screen)
        if self.holdSelector.GetSelected() == "Release":
            self.Release()
        elif self.holdSelector.GetSelected() == "Hold":
            self.Hold()

        if pygame.key.get_pressed()[pygame.K_h]:
            self.Hold()

        if pygame.key.get_pressed()[pygame.K_r]:
            self.Release()

        if self.drawMark:
            screen.blit(self.drawMark,(self.x + self.drawMarkX,self.y + self.drawMarkY))
项目:alienInvasionGame    作者:NilanjanaLodh    | 项目源码 | 文件源码
def check_keydown_events(self, event):
        if event.key == pygame.K_RIGHT:
            self.ship.moving_right = True
        elif event.key == pygame.K_LEFT:
            self.ship.moving_left = True
        elif event.key == pygame.K_SPACE:
            self.fire_bullet()
        elif event.key == pygame.K_q:
            sys.exit()
        elif event.key == pygame.K_h:
            self.display_help()