• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python display.update函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygame.display.update函数的典型用法代码示例。如果您正苦于以下问题:Python update函数的具体用法?Python update怎么用?Python update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: main

def main():
    rect = Rect((0, 0), SCREEN_SIZE)
    surface = Surface(SCREEN_SIZE)
    pxarray = PixelArray(surface)
    P = [(0, 100), (100, 0), (200, 0), (300, 100), (400, 200), (500, 200),
         (600, 100), (400, 400), (700, 50), (800, 200)]
    n = len(P) - 1 # n = len(P) - 1; (P[0], ... P[n])
    k = 3          # degree of curve
    m = n + k + 1  # property of b-splines: m = n + k + 1
    _t = 1 / (m - k * 2) # t between clamped ends will be evenly spaced
    # clamp ends and get the t between them
    t = k * [0] + [t_ * _t for t_ in xrange(m - (k * 2) + 1)] + [1] * k

    S = Bspline(P, t, k)
    # insert a knot (just to demonstrate the algorithm is working)
    S.insert(0.9)

    step_size = 1 / STEP_N
    for i in xrange(STEP_N):
        t_ = i * step_size
        try: x, y = S(t_)
        # if curve not defined here (t_ is out of domain): skip
        except AssertionError: continue
        x, y = int(x), int(y)
        pxarray[x][y] = (255, 0, 0)
    del pxarray

    for p in zip(S.X, S.Y): draw.circle(surface, (0, 255, 0), p, 3, 0)
    SCREEN.blit(surface, (0, 0))

    while 1:
        for ev in event.get():
            if ev.type == KEYDOWN:
                if ev.key == K_q: exit()
        display.update()
开发者ID:homata,项目名称:pycurve,代码行数:35,代码来源:bspline.py


示例2: do_button

def do_button(screen, ren, where, x, y):
    ren_rect = ren.get_rect().inflate(20, 10)
    if where == "topleft":
        ren_rect.topleft = screen.get_rect().topleft
        if x != None:
            ren_rect[0] = x
        if y != None:
            ren_rect[1] = y
    if where == "midtop":
        ren_rect.midtop = screen.get_rect().midtop
        if y != None:
            ren_rect[1] = y
    if where == "topright":
        ren_rect.topright = screen.get_rect().topright
        if x != None:
            ren_rect[0] = ren_rect[0] - x
        if y != None:
            ren_rect[1] = y
    if where == None:
        if x != None:
            ren_rect[0] = x
        if y != None:
            ren_rect[1] = ren_rect[1] + y
    screen.blit(ren, ren_rect.inflate(-20, -10))
    update(ren_rect)
    return ren_rect
开发者ID:paulmadore,项目名称:luckyde,代码行数:26,代码来源:buttons.py


示例3: paint_screen

def paint_screen(screen, color, *rect):
    if not rect:
        screen.fill(color)
        update()
    else:
        screen.fill(color, rect)
        update(rect)
开发者ID:paulmadore,项目名称:luckyde,代码行数:7,代码来源:img_screen.py


示例4: draw

    def draw(self):
        if self.drawn is False:
            Constants.SCREEN.fill((0, 0, 0))
            game_ended = self.title_font.render(self.dis_text, 1,
                                                (255, 255, 255))
            background = pygame.Surface(Constants.SCREEN.get_size())
            game_ended_rect = game_ended.get_rect()
            game_ended_rect.center = background.get_rect().center
            Constants.SCREEN.blit(game_ended, game_ended_rect)
            # Center our 'Press any key text'
            font = pygame.font.Font(None, 30)
            presskey = font.render("Press the ESC key to quit, or (m) "
                                   "to go back to the Menu", 1,
                                   (255, 255, 255))
            background = pygame.Surface(Constants.SCREEN.get_size())
            presskeyrect = presskey.get_rect()
            presskeyrect.centerx = background.get_rect().centerx
            presskeyrect.y = Constants.HEIGHT - 40
            Constants.SCREEN.blit(presskey, presskeyrect)

            alphaSurface = pygame.Surface((Constants.WIDTH,Constants.HEIGHT)) # The custom-surface of the size of the screen.
            alphaSurface.fill((0,0,0))
            alphaSurface.set_alpha(Constants.ALPHA_SURFACE) # Set the incremented alpha-value to the custom surface.
            Constants.SCREEN.blit(alphaSurface,(0,0))

            display.update()
            self.drawn = True
        else:
            pass
开发者ID:mattgor123,项目名称:CS255-ActionRPM,代码行数:29,代码来源:GameEnded.py


示例5: square_four

def square_four(screen, file):
    wait_cursor()
    draw_lines(screen)
    num_imgs = len(gl.files)
    if file >= num_imgs or file <= 0:
        file = 0
    img_four_name = gl.files[file]
    img_four_file = file
    img_four = load_img(img_four_name, screen, 0)
    file = file + 1
    img_four = adjust_img_size(img_four, screen.get_width(), screen.get_height())
    img_four_rect = img_four.get_rect()
    img_four_rect[0] = (screen.get_width() / 2)
    img_four_rect[1] = (screen.get_height() / 2)
    screen.blit(img_four, img_four_rect)
    update(img_four_rect)
    draw_lines(screen)
    if gl.FOUR_STATUS_BARS:
        font_size = 9
        font = pygame.font.Font(gl.FONT_NAME, font_size)
        name = os.path.basename(img_four_name)
        name = check_truncate(screen.get_width(), name)
        img_status = "%s [%d/%d]" % (name, img_four_file + 1, num_imgs)
        raise_up = 12
        show_message(screen, img_status, ((screen.get_width() / 2) + (screen.get_width() / 4 - font.size(img_status)[0]/2), screen.get_height() - raise_up), font_size, ("bold"))
    normal_cursor()
    return (file, img_four_rect, img_four_name, img_four_file)
开发者ID:paulmadore,项目名称:luckyde,代码行数:27,代码来源:four.py


示例6: __draw

 def __draw(self):
    
    self.__gen.draw(self.__canvas)
    
    
    if self.__mouseDown:
       diffX = self.__mouseCurrPos[0] - self.__mouseDownPos[0] 
       diffY = self.__mouseCurrPos[1] - self.__mouseDownPos[1]
       
       if diffX > 0 and diffY > 0:
          sizeX = max([diffX, diffY])
          sizeY = sizeX
       elif diffX > 0:
          sizeX = max([abs(diffX), abs(diffY)])
          sizeY = -sizeX
       elif diffY > 0:
          sizeY = max([abs(diffX), abs(diffY)])
          sizeX = -sizeY
       else:
          sizeX = min([diffX, diffY])
          sizeY = sizeX
       
          
       self.__drawSize = (sizeX, sizeY)
       
       pygame.draw.rect(self.__canvas, self.__highlightColor,
                        Rect(self.__mouseDownPos, self.__drawSize), 1)
    
    
    display.flip()
    display.update()
开发者ID:elizabeth-matthews,项目名称:atlasChronicle,代码行数:31,代码来源:fractalHandler.py


示例7: update_display

def update_display(update_queue):
    """(deque) -> NoneType
    Updates the display with Rect's given in update_queue, and clears update_queue. Specifically, for each such Rect,
    updates the display/screen only within that Rect."""
    display.update(update_queue)

    update_queue.clear()
开发者ID:Roolymoo,项目名称:fantasygame,代码行数:7,代码来源:main.py


示例8: start_editor

    def start_editor(self):
        glyph = self.editor_info
        glyph_rect = glyph.rect
        glyph.input(PAGES['editor'])
        glyph.update()
        editor = self.editor
        editor_rect = editor.rect
        SCREEN.blit(EDITOR_BKGSCREEN, (0, 0))
        SCREEN.blit(glyph.image, glyph_rect)
        SCREEN.blit(editor.image, editor_rect)
        editor_focus = False
        while 1:
            mouse_pos = mouse.get_pos()
            link = glyph.get_collisions(mouse_pos)
            if link: mouse.set_cursor(*HAND_CURSOR)
            else: mouse.set_cursor(*DEFAULT_CURSOR)
            for ev in event.get():
                if ev.type == MOUSEBUTTONDOWN:
                    if link: pass

                    if editor.rect.collidepoint(mouse_pos): editor_focus = True

                    else: editor_focus = False

                if ev.type == KEYDOWN:
                    if ev.key == K_ESCAPE: exit()
                    if editor_focus == True: editor.input(ev)

            cursor = editor.get_cursor()
            editor.image.fill((255, 205, 0), cursor)

            SCREEN.blit(editor.image, editor_rect)
            display.update()
开发者ID:LukeMS,项目名称:glyph,代码行数:33,代码来源:example.py


示例9: recoil

def recoil(attack, defend, move, me):
    """
    function
    """
    crit, type_, dmg = attack.calc_dmg(defend, move)
    ret1 = dmg_pkmn(defend, dmg, me)
    if dmg:
        meth = getattr(
            pokepong.move_sandbox, 'do_' + move.name.lower().replace(' ', '_').replace('-', '_'))
        meth(attack, defend, me)
    if crit:
        display.update(write_btm('Critical Hit!'))
        sleep(1)
    if type_ > 1:
        display.update(write_btm("It's Super Effective!"))
        sleep(1)
    elif 0 < type_ < 1:
        display.update(write_btm("It wasn't", "very effective!"))
        sleep(1)
    elif type_ == 0:
        display.update(write_btm("It had no effect"))
        sleep(1)
    ret2 = dmg_pkmn(attack, dmg / 4, not me)
    if ret2:
        display.update(write_btm(attack.name + ' was', 'hit with recoil!'))
    if ret1 and ret2:
        return 3
    elif ret1:
        return 1
    elif ret2:
        return 2
    else:
        return 0
开发者ID:nimbian,项目名称:pokepong,代码行数:33,代码来源:domove.py


示例10: print_version

def print_version(screen, screen_height):
    imgvlogo = load_img(gl.IMGV_LOGO_SMALL, screen, False)
    imgvlogo_rect = imgvlogo.get_rect()
    imgvlogo_rect[0] = 5
    imgvlogo_rect[1] = screen_height - 50
    screen.blit(imgvlogo, imgvlogo_rect)
    update(imgvlogo_rect)

    msg = "Version      %s" % gl.IMGV_VERSION
    msg_font = pygame.font.Font(gl.FONT_NAME, 11)
    msg_font.set_bold(1)
    char = 0
    i = 0
    pygame.event.set_blocked(MOUSEMOTION)
    while 1:
        event = pygame.event.poll()
        pygame.time.wait(1)
        check_quit(event)
        if char < len(msg):
            if msg[char] != ' ': # don't delay on spaces
                pygame.time.delay(75)
            ren = msg_font.render(msg[char], 1, gl.RED) # one char at a time
            ren_rect = ren.get_rect()
            # center it
            ren_rect[0] += (i + 7)
            ren_rect[1] = screen_height - 15
            screen.blit(ren, ren_rect)
            i += ren.get_width() # make letters space evenly
            char += 1
            update(ren_rect)
        else:
            break
开发者ID:paulmadore,项目名称:luckyde,代码行数:32,代码来源:help.py


示例11: draw

    def draw(self):
        """Draw all of the objects to the screen."""

        # Update all scene layers to the screen.
        self.all.update()
        self.dirty_rects = self.all.draw(self.screen)
        display.update(self.dirty_rects)
开发者ID:derrida,项目名称:shmuppy,代码行数:7,代码来源:scene.py


示例12: draw

    def draw(self):
        if self.timer >= GameIntro.delay:
            self.timer = 0
            if self.current_display == 2:
                # Constants.Levels = []
                # Constants.Levels.append(None)
                # Constants.Levels.append(None)
                # Constants.Levels[0] = Level_1.Level_1()
                Constants.PLAY = Play()
                Constants.STATE = Constants.PLAY
                #Constants.STATE = Play()
                Constants.STATE.set_level(0)
            else:
                self.current_display += 1
                Constants.SCREEN.fill(pygame.Color("black"))
                Constants.SCREEN.blit(GameIntro.images[self.current_display],
                                      self.rect)

                alphaSurface = pygame.Surface((Constants.WIDTH,Constants.HEIGHT)) # The custom-surface of the size of the screen.
                alphaSurface.fill((0,0,0))
                alphaSurface.set_alpha(Constants.ALPHA_SURFACE) # Set the incremented alpha-value to the custom surface.
                Constants.SCREEN.blit(alphaSurface,(0,0))
                
                display.update()
        else:
            pass
开发者ID:mattgor123,项目名称:CS255-ActionRPM,代码行数:26,代码来源:GameIntro.py


示例13: draw

 def draw(self):
     Constants.SCREEN.fill((0, 0, 0))
     Constants.SCREEN.blit(Volume.image,
                           Volume.image.get_rect(center=(Constants.WIDTH / 2, Constants.HEIGHT / 2)))
     Constants.SCREEN.blit(self.text, self.text_rect)
     Constants.SCREEN.blit(self.speedometer.image, self.speedometer.rect)
     display.update()
开发者ID:mattgor123,项目名称:CS255-ActionRPM,代码行数:7,代码来源:Volume.py


示例14: draw

    def draw(self):
        #Animate the car until we want a 'trail' of fire
        if self.steps * self.speed <= Constants.WIDTH:
            Constants.SCREEN.fill((0, 0, 0))
            #Center our 'Press any key text'
            font = pygame.font.Font(None, 30)
            presskey = font.render("Press any key to continue to the Menu", 1,
                                   (255, 255, 255))
            background = pygame.Surface(Constants.SCREEN.get_size())
            presskeyrect = presskey.get_rect()
            presskeyrect.centerx = background.get_rect().centerx
            presskeyrect.y = Constants.HEIGHT - 40
            Constants.SCREEN.blit(presskey, presskeyrect)
        #Move the car until it's off the screen
        if self.rect.left <= Constants.WIDTH:
            self.rect.midright = (self.steps * self.speed, Constants.HEIGHT
                                  / 2)
            Constants.SCREEN.blit(self.image, self.rect)
        #Once it's off the screen, show our ActionRPM text
        else:
            label = self.font.render("ActionRPM", 1, (0, 0, 0))
            Constants.SCREEN.blit(label, (Constants.WIDTH / 3.5,
                                          Constants.HEIGHT / 3))

        alphaSurface = pygame.Surface((Constants.WIDTH,Constants.HEIGHT)) # The custom-surface of the size of the screen.
        alphaSurface.fill((0,0,0))
        alphaSurface.set_alpha(Constants.ALPHA_SURFACE) # Set the incremented alpha-value to the custom surface.
        Constants.SCREEN.blit(alphaSurface,(0,0))

        display.update()
开发者ID:mattgor123,项目名称:CS255-ActionRPM,代码行数:30,代码来源:Title.py


示例15: dmg_pkmn

def dmg_pkmn(pkmn, dmg, me):
    """
    function
    """
    if pkmn.substitute == 0:
        if pkmn.bide:
            pkmn.bidedmg += dmg * 2
        if dmg > 0:
            for d in range(dmg):
                if pkmn.hp <= 0:
                    return 1
                pkmn.sethp(pkmn.hp - 1)
                if not me:
                    display.update(draw_my_hp(pkmn))
                else:
                    display.update(draw_opp_hp(pkmn))
                sleep(.02)
        else:
            for d in range(0, dmg, -1):
                if pkmn.maxhp == pkmn.hp:
                    break
                pkmn.sethp(pkmn.hp + 1)
                if not me:
                    display.update(draw_my_hp(pkmn))
                else:
                    display.update(draw_opp_hp(pkmn))
                sleep(.02)

        return 0
    else:
        pkmn.substitute -= dmg
        if pkmn.substitute < 1:
            pkmn.substitute = 0
            display.update(write_btm('The substitute broke'))
            sleep(1)
开发者ID:nimbian,项目名称:pokepong,代码行数:35,代码来源:domove.py


示例16: view_filter

def view_filter(screen):
    paint_screen(screen, gl.BLACK)
    show_message(screen, "Current filter", "top", 20, ("underline", "bold"))
    show_message(screen, "Imgv will only display files whose filenames:", (5, 30), 15, ("bold"))
    line = 60
    for k in gl.FILTER_COMMAND.keys():
        font = pygame.font.Font(gl.FONT_NAME, 12)
        if k == "startwith":
            ren = font.render("Start with: %s" % gl.FILTER_COMMAND["startwith"], 1, (255, 255, 255), (0, 0, 0))
        if k == "notstartwith":
            ren = font.render("Do not start with:  %s" % gl.FILTER_COMMAND["notstartwith"], 1, (255, 255, 255), (0, 0, 0))
        if k == "endwith":
            ren = font.render("End with:  %s" % gl.FILTER_COMMAND["endwith"], 1, (255, 255, 255), (0, 0, 0))
        if k == "notendwith":
            ren = font.render("Do not end with:  %s" % gl.FILTER_COMMAND["notendwith"], 1, (255, 255, 255), (0, 0, 0))
        if k == "contain":
            ren = font.render("Contain:  %s" % gl.FILTER_COMMAND["contain"], 1, (255, 255, 255), (0, 0, 0))
        if k == "notcontain":
            ren = font.render("Do not contain:  %s" % gl.FILTER_COMMAND["notcontain"], 1, (255, 255, 255), (0, 0, 0))
        ren_rect = ren.get_rect()
        ren_rect[0] = 5
        ren_rect[1] = line
        screen.blit(ren, ren_rect)
        line = line + 30
        update(ren_rect)
    while 1:
        ev = pygame.event.wait()
        check_quit(ev)
        if ev.type == KEYDOWN or ev.type == MOUSEBUTTONDOWN:
            return
开发者ID:paulmadore,项目名称:luckyde,代码行数:30,代码来源:filter_files.py


示例17: absorb

def absorb(attack, defend, move, me):
    """
    function
    """
    if move.name == 'Dream Eater':
        if 'SLP' not in defend.buffs:
            display.update(write_btm('but it failed!'))
            sleep(1)
            return 0
    crit, type_, dmg = attack.calc_dmg(defend, move)
    if crit:
        display.update(write_btm('Critical Hit!'))
        sleep(1)
    if type_ > 1:
        display.update(write_btm("It's Super Effective!"))
        sleep(1)
    elif 0 < type_ < 1:
        display.update(write_btm("It wasn't", "very effective!"))
        sleep(1)
    elif type_ == 0:
        display.update(write_btm("It had no effect"))
        sleep(1)
    retval = dmg_pkmn(defend, dmg, me)
    if retval:
        meth = getattr(
            pokepong.move_sandbox, 'do_' + move.name.lower().replace(' ', '_').replace('-', '_'))
        meth(attack, defend, me)
    dmg_pkmn(attack, int(floor(dmg / 2) * -1), not me)
    return retval
开发者ID:nimbian,项目名称:pokepong,代码行数:29,代码来源:domove.py


示例18: _display_with_pygame

    def _display_with_pygame(self, imagefile):
        try:
            t1 = time.time()
            # Clear the screen
            self._blank_screen()
            logging.debug('Time: {0}'.format(time.time() - t1))
            img = image.load(imagefile)
#            img = pygame.image.load(imagefile).convert()
            logging.debug(time.time() - t1)
            img, offset_x, offset_y = self.scale_image(img)
            logging.debug(time.time() - t1)
            self._screen.blit(img, (offset_x, offset_y))
            logging.debug(time.time() - t1)

            # update the display
            display.update()
            logging.debug('Time image displayed: {0}'.format(time.time() - t1))
            ''' fadeIn? from black '''
            # pygame.display.flip()
            # pause
            pygame_time.wait(self._image_display_time * 1000)

            # time.sleep(self._image_display_time)
            ''' fadeOut? to black '''

        except Exception, e:
            logging.error('Error: ' + str(e))
开发者ID:mikostn,项目名称:pi_video_looper,代码行数:27,代码来源:omx_image_player.py


示例19: do_view_tagged

def do_view_tagged(screen, num_imgs, file):
    "show all tagged dir names"
    paint_screen(screen, gl.BLACK)
    (esc_rect, close_font) = close_button(screen)
    line = 5
    if len(gl.MULT_DIRS) == 0:
        show_message(screen, "[No directories are currently tagged]", "bottom", 12)
    for d in gl.MULT_DIRS:
        font = pygame.font.Font(gl.FONT_NAME, 9)
        ren = font.render(d, 1, (255, 255, 255), (0, 0, 0))
        ren_rect = ren.get_rect()
        ren_rect[0] = 5
        ren_rect[1] = line
        screen.blit(ren, ren_rect)
        line = line + 12
        update(ren_rect)
    pygame.event.set_allowed(MOUSEMOTION)
    while 1:
        ev = pygame.event.wait()
        check_quit(ev)
        hover_cursor(pygame.mouse.get_pos(), (esc_rect,))
        if ev.type == KEYDOWN and ev.key not in (K_LALT, K_RALT, K_TAB, K_LCTRL, K_RCTRL) or ev.type == MOUSEBUTTONDOWN:
            gl.ADDED_DIR_NUMS = 0
            (num_imgs, file) = show_dirs(screen, num_imgs, file)
            break # break event loop
开发者ID:paulmadore,项目名称:luckyde,代码行数:25,代码来源:dir_nav.py


示例20: change_box

def change_box(screen, positions):
    change_img = load_img(gl.CHANGE_BOX, False)
    change_rect = change_img.get_rect()
    change_rect[0] = positions[1]
    change_rect[1] = positions[0]
    screen.blit(change_img, change_rect)
    update(change_rect)
    return change_rect
开发者ID:rkulla,项目名称:imgv,代码行数:8,代码来源:edit.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python draw.circle函数代码示例发布时间:2022-05-25
下一篇:
Python display.set_mode函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap