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


Python Ball.vSetPos方法代码示例

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


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

示例1: game_stage_001

# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import vSetPos [as 别名]

#.........这里部分代码省略.........
                    return
                elif self.msg == "YOU WIN":
                    self.state = "END"
                    return
                self.Message_rect.center = (self.Message_rect.center[0]+18,  self.Message_rect.center[1])


        if self.ship.state == "DEAD" and self.ship.frame == len(self.ship.imageDead)-1:
            self.msg = "GAME OVER"
            self.Message = self.bigfont.render("",True,( 255, 255, 255))
            self.Message_rect.center = (512, 382)

        if self.boss.life <= 0 and self.boss.state == "DEAD_LEFT":
            self.msg = "YOU WIN"
            self.Message = self.bigfont.render("",True,( 255, 255, 255))
            self.Message_rect.center = (512, 382)

        for event in pygame.event.get():
            if event.type == QUIT:
                exit()
            if event.type == KEYDOWN :
                #print pygame.key.name(275)
                if event.key == 276:
                    self.space_dir = "LEFT"
                    self.mouse_move = False
                elif event.key == 275:
                    self.space_dir = "RIGHT"
                    self.mouse_move = False

                elif event.key == K_SPACE:
                    if self.ball.Enable == False:
                        self.ship.energy -= 1
                        #self.ball.Enable = True
                        self.ball.vSetPos(self.ship.rect[0]+(self.ship.rect[2]/2), self.ship.rect[1]+self.ship.rect[3]+(self.ship.rect[3]/2))
##                elif event.key == K_UP:
##                    self.BlockMgr.vMoveUp()
            elif event.type == KEYUP:
                    self.space_dir = "IDLE"
                    if event.key == K_q:
                        self.state = "QUIT"
                        return
            elif event.type == MOUSEMOTION:
                self.mouse_pos = event.pos
                self.mouse_move = True
            elif event.type == MOUSEBUTTONDOWN:
                if self.ball.Enable == False:
                    self.ship.energy -= 1
                    #self.ball.Enable = True
                    self.ball.vSetPos(self.ship.rect[0]+(self.ship.rect[2]/2), self.ship.rect[1]+self.ship.rect[3]+(self.ship.rect[3]/2))
            else:
                self.space_dir = "IDLE"

        #print self.ball.rect

        if self.space_dir == "LEFT" :
            self.ship.vMoveLeft()
        elif self.space_dir == "RIGHT":
            self.ship.vMoveRight()
        elif self.mouse_move == True:
            if self.mouse_pos[0] < self.ship.fGetPos()[0]:
                self.ship.vMoveLeft()
            if self.mouse_pos[0] > self.ship.fGetPos()[0]:
                self.ship.vMoveRight()
            if self.mouse_pos[0] == self.ship.fGetPos()[0]:
                self.mouse_move = False
                self.ship.vIdle()
开发者ID:j4cksw,项目名称:sky,代码行数:70,代码来源:game_stage_001.py


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