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


Python Ship.tick方法代码示例

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


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

示例1: __init__

# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import tick [as 别名]
class GameSpace:
    def __init__(self, queue, port):
        pygame.init()

        self.size = self.width, self.height = (1400, 600)
        self.black = 0, 0, 0

        self.screen = pygame.display.set_mode(self.size, 0, 32)

        self.mouse_pos = [0,0]

        self.gameStarted = False
        self.gameOver = 0
        self.cease = False
        self.queue = queue

        self.player = 0
        if port == 40084:
            self.player = 1
        else:
            self.player = 2

        self.menu = Menu(self, "main_menu.csv")
        self.menu.tick()
        self.myShip = None
        self.otherShip = None

    def update(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                reactor.stop()
                pygame.quit()
                try:
                    sys.exit()
                except BaseException:
                    pass
                break
            elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                # http://stackoverflow.com/questions/12150957/pygame-action-when-mouse-click-on-rect
                self.mouse_pos = pygame.mouse.get_pos()
                if self.gameStarted:
                    pass
                    #self.queue.put("DATA DATA DATA")
                else:
                    # Check if any options have been selected in the menus
                    p = self.menu.clickHandler(self.mouse_pos)
                    print p
                    if p == "PLAY":
                        self.menu = Menu(self, "ship_menu.csv")
                        self.menu.tick()
                    elif p == "Blueship" or p == "Cruiser":
                        self.queue.put(p)
                        self.screen.fill(self.black)
                        self.myShip = Ship(self,p.lower(),str(self.player))
                        self.gameStarted = True
        
        # If game over, broadcast winner and show end screen
        if self.gameOver and not self.cease:
            self.queue.put("END " + str(self.gameOver))
            self.gameStarted = False
            self.cease = True
            self.screen.fill(self.black)
            myfont = pygame.font.SysFont("monospace",50)
            label = myfont.render("Player " + str(self.gameOver) + " WINS!", 1, (255,0,0))
            self.screen.blit(label, (650, 300))

        # should everything from here forward be unindented by one block? so multiple events can occur on one tick?
        if self.gameStarted:
            self.screen.fill(self.black)
            self.myShip.tick()
            if self.otherShip != None:
                self.otherShip.tick()

        pygame.display.flip()
        self.mouse_pos = (0,0)
开发者ID:atowneND,项目名称:Paradigms_Final_Project,代码行数:77,代码来源:gamespace.py


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