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


Python Picture.draw_part方法代码示例

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


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

示例1: run_title

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import draw_part [as 别名]

#.........这里部分代码省略.........
            if e.type == pygame.QUIT:
                run.quit = True
            elif e.type == pygame.KEYDOWN:
                if e.key == pygame.K_ESCAPE:
                    rects[3][4]()
                if e.key == pygame.K_RETURN:
                    rects[0][4]()
            elif e.type == pygame.MOUSEBUTTONUP:
                x, y = e.pos
                if e.button == 1:
                    if selected != None:
                        selected[4]()

        mx, my = pygame.mouse.get_pos()

        glClearColor(1, 0.6, 0.4, 1)
        glClear(GL_COLOR_BUFFER_BIT)

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()

        glEnable(GL_TEXTURE_2D)
        glEnable(GL_BLEND)
        glBlendFunc(GL_ONE, GL_ONE)

        t += 1
        tt = (t * 4) % (480 + 512)

        game.background1.draw_centered(0, 0)
        game.background1.draw_centered(640, 480)
        game.background1.draw_centered(320, tt)
        game.background1.draw_centered(320, tt - 512 - 480)

        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        selected = None
        black = {"red" : 0, "green" : 0, "blue" : 0}
        beat = (t % 30)
        if beat < 20: beat = 0
        else:
            if beat < 25: beat = (beat - 20) / 5.0
            else: beat = 1 - (beat - 25) / 5.0
        d = (t / 30) % 3
        a, b, c = ((0.5, 0.5, 0), (0.5, 0, 0.5), (0, 0.5, 0.5))[d]
        flash = {"red" : beat * a, "green" : beat * b, "blue" : beat * c}
        d = 160.0
        if t < d:
            tt = 1 - t / d

            title.draw(0, 0 - tt * 480, **flash)
            subtitle.draw(0, 0 + tt * 480, **black)
            menu.draw(0 + tt * 640, 0, **black)
            menu2.draw(0 - tt * 640, 0, **black)
        elif t < d * 2:
            tt = t - d
            tt = tt / d

            title.draw(0, 0, **flash)
            subtitle.draw(0, -tt * 220, **black)
            menu.draw(240 * tt, 80 * tt, **black)
            menu2.draw(-80 * tt, 80 * tt, **black)
        else:
            tt = (t - d * 2) / d
            if tt > 1.0: tt = 1.0
            title.draw(0, 0, **flash)
            subtitle.draw(0, -220, **black)
            glPushMatrix()
            glTranslate(240 + 550, 80 + 350, 0)
            glRotate(10 * math.sin(1 * 2 * math.pi * (t - d * 2) / 60), 0, 0, 1)
            glTranslate(-550, -350, 0)
            menu.draw(0, 0, **black)
            glPopMatrix()
            menu2.draw(-80, 80, **black)
            menu3.draw(0, 0, red = 0, green = 0, blue = 0, alpha = tt)

            for r in rects:
                if mx >= r[0] and my >= r[1] and mx <= r[2] and my <= r[3]:
                    selected = r
                    glBlendFunc(GL_SRC_ALPHA, GL_ONE)
                    menu3hl.draw_part(r[0] - 8, r[1] - 8, r[0] - 8, r[1] - 8, r[2] + 8, r[3] + 8)
                    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
                    menu3.draw_part(r[0] - 8, r[1] - 8, r[0] - 8, r[1] - 8, r[2] + 8, r[3] + 8,
                        red = 1, green = 0.5, blue = 0, alpha = 0.5)
                    selected = r

            glBlendFunc(GL_SRC_ALPHA, GL_ONE)
            x, y = 395 + 230 * (run.last_level - 1) / 7, 245
            menu3hl.draw_part(x, y, x, y, 395 + 230 * run.last_level / 7, 290)
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
            menu3hl.draw_part(x, y, x, y, 395 + 230 * run.last_level / 7, 290,
                red = 1, green = 0.5, blue = 0, alpha = 0.5)

        cursor.draw_centered(mx, my)

        pygame.display.flip()

        ft = pygame.time.get_ticks()
        pygame.time.wait(int(title.next - ft))
        ft = title.next
        title.next = ft + 1000.0 / run.FPS
开发者ID:allefant,项目名称:allefant5,代码行数:104,代码来源:title.py


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