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


Python Interface.draw方法代码示例

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


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

示例1: fight

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import draw [as 别名]
    def fight(self, screen):
        interface = Interface()
        interface.addObject(self.board, (0, 0))
        done = False
        clock = pygame.time.Clock()
        interface.draw(screen)
#        while not done:
        turnMade = False
        while self.board.countTeams() > 1 :
            if done: 
                exit() 
            curWar = self.board.getWill()
            curWar.current
            if curWar.curPoints == 0:
                turnMade = True            
            key = ""
            self.board.draw(screen)
            deb (1, "It time to go," + str(curWar.name))
            if not curWar.human:
                curWar.updateBot(self.board)
            for event in pygame.event.get():
                if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
                    done = True 
                if curWar.human: 
                    pos = pygame.mouse.get_pos() 
                    # print pos
                    if event.type == pygame.KEYDOWN:
#                         if event.key ==  pygame.K_LEFT:
#                             direction = "l"
#                         elif event.key ==  pygame.K_RIGHT:
#                             direction = "r"
#                         elif event.key ==  pygame.K_UP:
#                             direction = "u"   
#                         elif event.key ==  pygame.K_DOWN:
#                             direction = "d"
                        if event.key == pygame.K_SPACE:
                            turnMade = True
#                         if   direction in "udlr": 
                            # while not event.type == pygame.KEYUP: continue
                              
                    if event.type == pygame.MOUSEBUTTONDOWN:
                        #print "left button clicked"
                        if event.button == 1:
                            # print pos
                            obj, intPos = interface.getObjectByPos(pos)
                            obj.onClick((pos[0] - intPos[0], pos[1] - intPos[1]))

            if turnMade:
                self.endTurn(curWar)
                turnMade = False
                curWar.current = False

            deb(2, "Now you should press Enter")
            
            pygame.display.flip()
            pygame.display.update() 
            clock.tick(5)
开发者ID:korney4eg,项目名称:board_rpg,代码行数:59,代码来源:game.py

示例2: __init__

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import draw [as 别名]
class Game:
    def __init__(self, size, manager=None, player_one=None,
                 player_two=None, rnd=1, online=None):
        self.size = size
        self.manager = manager
        if manager is not None:
            self.manager.load_images(size)
            self.interface = Interface(size,
                                   self.manager.img_dict,
                                   self.manager.options)
        self.person = 1
        self.online = online
        self.end = False
        self.message = None
        self.players = {1-2*rnd: player_one, -1+2*rnd: player_two}
        self.points = {-1: 2, 1: 2}
        self.active = False
        self.load = 0
        self.field = [[0] * size for i in range(size)]
        self.size = size
        if manager is not None:
            self.interface.set_information(self.points, self.person, self.players)

    def is_end(self):
        return self.end

    def the_end(self):
        self.end = True

    def descend(self, x, y):
        pass

    def get_valid_path(self):
        pass

    def start(self):
        pass

    def event(self, events):
        pass

    def update(self, dt):
        if not self.active:
            if self.load <= PASSIVE:
                self.load += dt
            else:
                self.active = True

    def draw(self, display):
        path = self.valid_path if (self.players[self.person] == Player.man) \
            else {}
        self.interface.draw(display, self.field, path)
开发者ID:Anovi-Soft,项目名称:Python,代码行数:54,代码来源:Game.py

示例3: start

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import draw [as 别名]
def start(size):
    main_clock = pygame.time.Clock()
    pygame.display.init()
    window  = pygame.display.set_mode(size)
    window_ = window.copy() 
    b = Ball()
    r_right   = Racket('R')
    r_left    = Racket('L')
    while True:
        # Event manager
        for event in pygame.event.get():
            if event.type == QUIT:
                end()
            elif event.type == MOUSEBUTTONDOWN:
                if event.button == 1:
                    pass
            elif event.type == KEYDOWN:
                #print(event.key)
                if event.key == 273: # Direction key up
                    r_right.direction = 'up'
                    break
                if event.key == 274: # Direction key down
                    r_right.direction = 'down'
                    break
            r_right.direction = False
                    
        window.blit(window_, (0, 0))
        r_right.draw(window)
        r_right.update()
        r_left.computerAI(b)
        r_left.draw(window)
        r_left.update()
        b.draw(window)
        b.update()
        b.collides(r_right, r_left)
        Interface.draw(window, r_left.mark, r_right.mark)
        pygame.display.flip()
        main_clock.tick(100)
开发者ID:Margaruga,项目名称:Games,代码行数:40,代码来源:main.py


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