當前位置: 首頁>>代碼示例>>Python>>正文


Python Background.setSpeed方法代碼示例

本文整理匯總了Python中background.Background.setSpeed方法的典型用法代碼示例。如果您正苦於以下問題:Python Background.setSpeed方法的具體用法?Python Background.setSpeed怎麽用?Python Background.setSpeed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在background.Background的用法示例。


在下文中一共展示了Background.setSpeed方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from background import Background [as 別名]
# 或者: from background.Background import setSpeed [as 別名]

#.........這裏部分代碼省略.........

        # Number of Player Health
        self.health = self.spaceship.getHitPoints()

        # Kill Points
        self.kills = 0

        # Display the health
        self.health_color = (255,255,255)
        self.health_x     = self.width/2
        self.health_y     = self.height - 30

        # Display the Score
        self.score_color = (0,150,0)
        self.score_x     = 20
        self.score_y     = 50



        return

    def evolve(self, keys, newkeys, buttons, newbuttons, mouse_position):
        
        self.bg.update()    # Update Background
        if pygame.K_w in keys:
            self.spaceship.setHitPoints(10)
            self.spaceship.setWidth(225)
            self.spaceship.setHeight(75)
            self.spaceship.setImage('pelican_250x99.png')
            self.spaceship.setName('Pelican')
            self.spaceship_speed       = 15
            self.health = self.spaceship.getHitPoints()
            self.bullet_sound = self.pelican_shoot
            self.bg.setSpeed(-20)


        if pygame.K_LEFT in keys:
            self.spaceship.moveLeft(self.spaceship_speed)
        if pygame.K_RIGHT in keys:
            self.spaceship.moveRight(self.spaceship_speed,self.upper_limit)
        if pygame.K_UP in keys:
            self.spaceship.moveUp(self.spaceship_speed)
        if pygame.K_DOWN in keys:
            self.spaceship.moveDown(self.spaceship_speed,self.height)

        if self.spaceship.getAlive() == True:   # If space ship is alive, then
                                                # it can fire.
            if pygame.K_SPACE in newkeys:
                self.bullet_sound.play()
                self.bullets.append(self.spaceship.fire(self.bullet_width,
                                                        self.bullet_height,
                                                        self.bullet_color))

        if pygame.K_q in newkeys:
            print "PRESSED Q"
            pygame.quit()
            return

        if pygame.K_r in keys:
            print "GAME RESTARTED"
            self.__init__(1024, 768, 30)
            return



        if random.randint(1, self.frame_rate/2) == 1:
開發者ID:rickspartanimpreza,項目名稱:my-halo,代碼行數:70,代碼來源:SpaceshipData.py


注:本文中的background.Background.setSpeed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。