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


Python Ship.stop_move_down方法代码示例

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


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

示例1: Vacuum

# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import stop_move_down [as 别名]

#.........这里部分代码省略.........
                return
            elif event.type == KEYDOWN and event.key == K_ESCAPE and self.game_finished == True:
                pygame.quit()
                quit()
                
            if event.type == KEYDOWN:
                self.game_started = True
                if event.key == K_ESCAPE:
                    return false   #exit
                elif event.key == K_SPACE:
                    #shoot a laser if the max number is not reached
                    if Laser.num < Laser.max_lasers:
                        self.laser = Laser(self.ship)
                        self.fire.add(self.laser)
                elif event.key == K_LEFT:
                    self.ship.move_left()
                elif event.key == K_RIGHT:
                    self.ship.move_right()
                elif event.key == K_UP:
                    self.ship.move_up()
                elif event.key == K_DOWN:
                    self.ship.move_down()
                elif event.key == K_p:
                    self.game_paused = not self.game_paused

            if event.type == KEYUP:
                if event.key == K_LEFT:
                    self.ship.stop_move_left()
                elif event.key == K_RIGHT:
                    self.ship.stop_move_right()
                elif event.key == K_UP:
                    self.ship.stop_move_up()
                elif event.key == K_DOWN:
                    self.ship.stop_move_down()

        return True

    def process_powerups(self):
        #powerups got by the player, remove them, play a sound and apply them
        powerups_obtained  = pygame.sprite.spritecollide(self.ship, self.powerups, True)
        for powerup_obtained in powerups_obtained:
            #play powerup sound
            self.sounds['powerup'].play()
            #TODO powerup should be processed in ship
            if powerup_obtained.type == 1 and self.ship.powerup['speedup'] < 2:
                self.ship.powerup['speedup'] += 0.5 
                print "Increase speed to {0}".format(self.ship.powerup['speedup'])
            elif powerup_obtained.type == 2 and Laser.max_lasers < 8:
                print "Increase lasers to {0}".format(Laser.max_lasers)
                Laser.max_lasers += 1 
            elif powerup_obtained.type == 3 and self.ship.powerup['penetrate'] == False:
                print "Activate penetration"
                self.ship.powerup['penetrate'] = True
            else:
                print "No more powerups available"

    #Main Loop
    def loop(self):
        count = 0
        while 1:
            count = (count+1)%50
            self.clock.tick(25)

            #handle input events
            ok = self.handle_keys()
            if ok == False:
开发者ID:codelurker,项目名称:VacuumFire,代码行数:70,代码来源:main.py

示例2: Vacuum

# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import stop_move_down [as 别名]

#.........这里部分代码省略.........
                if event.key == K_ESCAPE:
                    return False   #exit
                elif event.key == K_SPACE:
                    #shoot a laser if the max number is not reached
                    if Laser.num < Laser.max_lasers:
                        #print "There's {0} lasers in the screen and the max is {1}".format(Laser.num, Laser.max_lasers)
                        laser = Laser(self.ship)
                        self.fire.add(laser)
                        if self.ship.buddies > 0:
                            self.fire.add(DiagonalLaser(self.ship, "up"))
                        if self.ship.buddies > 1:
                            self.fire.add(DiagonalLaser(self.ship, "down"))
                        if self.ship.buddies > 2:
                            self.fire.add(DiagonalLaser(self.ship, "back"))
                elif event.key == K_LEFT:
                    self.ship.move_left()
                elif event.key == K_RIGHT:
                    self.ship.move_right()
                elif event.key == K_UP:
                    self.ship.move_up()
                elif event.key == K_DOWN:
                    self.ship.move_down()
                elif event.key == K_p:
                    self.game_paused = not self.game_paused

            if event.type == KEYUP:
                if event.key == K_LEFT:
                    self.ship.stop_move_left()
                elif event.key == K_RIGHT:
                    self.ship.stop_move_right()
                elif event.key == K_UP:
                    self.ship.stop_move_up()
                elif event.key == K_DOWN:
                    self.ship.stop_move_down()

        return True

    def process_powerups(self):
        #powerups got by the player, remove them, play a sound and apply them
        powerups_obtained  = pygame.sprite.spritecollide(self.ship, self.powerups, True)
        for powerup_obtained in powerups_obtained:
            #play powerup sound
            self.sounds['powerup'].play()
            self.score.add_score(powerup_obtained.value)
            #TODO powerup should be processed in ship
            print 'powerup:',powerup_obtained.type
            if powerup_obtained.type == 0:
                self.ship.life_up()
                self.hud.add(Flying_Label( self.ship.rect, 'Energy'))
                self.lifemeter.life = self.ship.life
            elif powerup_obtained.type == 1 and self.ship.powerup['speedup'] < 5:
                self.ship.powerup['speedup'] += 1 
                self.powerup_speed.set_status(self.ship.powerup['speedup'])
                self.hud.add(Flying_Label( self.ship.rect, 'Speed up'))
                #print "Increase speed to {0}".format(self.ship.powerup['speedup'])
            elif powerup_obtained.type == 2 and Laser.max_lasers < 5:
                Laser.max_lasers += 1 
                Laser.move += 2 
                self.powerup_weapon.set_status(Laser.max_lasers)
                print "Increase lasers to {0}".format(Laser.max_lasers)
                self.hud.add(Flying_Label( self.ship.rect, 'Lasers'))

            elif powerup_obtained.type == 3 and self.ship.powerup['penetrate'] == False:
                print "Activate penetration"
                self.hud.add(Flying_Label( self.ship.rect, 'Penetration'))
                self.ship.powerup['penetrate'] = True
开发者ID:timepilot,项目名称:VacuumFire,代码行数:70,代码来源:vacuum.py


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