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


Python Picture.draw方法代码示例

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


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

示例1: PygameStarter

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import draw [as 别名]
class PygameStarter(game_mouse.Game):

    def __init__(self, width, height):

        game_mouse.Game.__init__(self, "Pygame Starter",
                                 width,
                                 height,
                                 10)
        
        self.font_height = 12
        self.font = pygame.font.SysFont("Courier New", self.font_height)

        self.mPicture = Picture()
        return
        
        
    def game_logic(self, keys, newkeys, buttons, newbuttons, mouse_position):
        x = mouse_position[0]
        y = mouse_position[1]

        if pygame.K_a in newkeys:
            print "a key pressed"
        
        if 1 in newbuttons:
            print "button clicked"

        return
    
    def paint(self, surface):
        self.mPicture.draw(surface)
        return
开发者ID:joshl8n,项目名称:school-projects,代码行数:33,代码来源:pygame_starter.py

示例2: run_title

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import draw [as 别名]
def run_title():
    class Title: pass
    run.quit = False
    game = run.game

    title = Picture("title.png")
    subtitle = Picture("subtitle.png")
    menu = Picture("menu.png")
    menu2 = Picture("menu2.png")
    menu3 = Picture("menu3.png")
    menu3hl = Picture("menu3hl.png")

    cursor = Picture("mouse.png")

    if not run.config.nomusic:
        pygame.mixer.music.load(data.filepath("loop/menu.ogg"))
        pygame.mixer.music.play(-1)

    def button_ng():
        run.run_game()
        if not run.config.nomusic:
            pygame.mixer.music.load(data.filepath("loop/menu.ogg"))
            pygame.mixer.music.play(-1)
        title.next = pygame.time.get_ticks() + 1000.0 / run.FPS

    def button_next():
        if run.last_level < run.config.level: run.last_level += 1

    def button_prev():
        if run.last_level > 1: run.last_level -= 1

    def button_fs():
        run.config.fullscreen = not run.config.fullscreen
        run.config.save()
        main.main()

    def button_nm():
        run.config.nomusic = not run.config.nomusic
        if not run.config.nomusic:
            pygame.mixer.music.load(data.filepath("loop/menu.ogg"))
            pygame.mixer.music.play(-1)
        else:
            pygame.mixer.music.stop()
        run.config.save()

    def button_q():
        run.quit = True

    rects = (
        (220, 274, 417, 323, button_ng),
        (170, 344, 320, 400, button_fs),
        (340, 344, 470, 400, button_nm),
        (283, 417, 358, 466, button_q),
        (130, 260, 210, 286, button_next),
        (130, 301, 210, 326, button_prev),
        )

    selected = None
    t = 0
    title.next = pygame.time.get_ticks() + 1000 / run.FPS
    while not run.quit:

        for e in pygame.event.get():
            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}
#.........这里部分代码省略.........
开发者ID:allefant,项目名称:allefant5,代码行数:103,代码来源:title.py


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