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


Python Engine.add_player方法代码示例

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


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

示例1: main

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import add_player [as 别名]
def main():
    #Initialize Everything
    pygame.init()
    WIDTH, HEIGHT = 1024, 720 
    screen = pygame.display.set_mode((WIDTH, HEIGHT))
    pygame.display.set_caption('Yxkull')
    pygame.mouse.set_visible(0)

    #Create The Backgound
    if 1:
        background = pygame.Surface(screen.get_size())
        background = background.convert()
        background.fill((250, 250, 250))
    else:
        background, bg_rect = load_image('background.bmp')

    hud = None

    # Add walls to the background
    
    # Joysticks
    JOYSTICKS = pygame.joystick.get_count()
    PLAYERS = 2 * JOYSTICKS 
    joysticks = [pygame.joystick.Joystick(i) for i in xrange(JOYSTICKS)]  

    for i, j in enumerate(joysticks):
        j.init()
        print j.get_numaxes()


    axes = []
    for j in xrange(JOYSTICKS):
        for i in xrange(2):
            def _get_axis(axis, joysticks):
                return joysticks[j].get_axis(i*2+axis)            
            axes.append(_get_axis)

    #print axes

    engine = Engine((WIDTH, HEIGHT))
    
    colors = [(100, 0, 0), (0, 100, 0), (0, 0, 100), (100, 0, 100)]
    
    for p in xrange(PLAYERS):
        player = Player(engine, colors[p], axes[p])
        #player.pos = positions[p]
        engine.add_player(player)

    #players += [Player(j, (0, 100*(1-i), 100*i))]

    screen.blit(background, (0, 0))
    pygame.display.flip()


    heart, heart_rect = load_image('heart.bmp', -1)
    num_hearts_generated = -1

    clock = pygame.time.Clock()

    engine.reset()

    while 1:
        clock.tick(60)

        for event in pygame.event.get():
            if event.type == QUIT:
                return
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                return
            elif event.type == MOUSEBUTTONDOWN:
                pass
            elif event.type is MOUSEBUTTONUP:
                pass
            elif event.type == KEYDOWN and event.key == K_SPACE:
                if engine.game_over:
                    engine.reset() 

        for j in xrange(JOYSTICKS):
            for i in xrange(2):
                p = engine.players[j*2+i]
                p.apply_control(joysticks[j].get_axis(i*3), joysticks[j].get_axis(i*3+1))
    
    
        engine.process()

        # Draw
        screen.blit(background, (0, 0))

        #for p in engine.entities:
            #pygame.draw.circle(screen, p.color, p.pos, p.radius) 

        #for p in engine.players:
        #    pygame.draw.circle(screen, p.color, p.pos, p.radius) 

        engine.draw(screen)

        for beam in engine.beams:
            pygame.draw.line(screen, beam.color, beam.pos1, beam.pos2, beam.width)

        if engine.game_over:
#.........这里部分代码省略.........
开发者ID:poopas,项目名称:yxkull,代码行数:103,代码来源:yxkull.py

示例2: Engine

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import add_player [as 别名]
from engine import Engine
e = Engine()
e.add_player()
e.update_velocity('red', (1, 1))
开发者ID:vhp-jjh,项目名称:online-tag,代码行数:6,代码来源:test_engine.py


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