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


Python display.get_surface函数代码示例

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


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

示例1: draw

    def draw(self):
        viewport = display.get_surface()
        if self.menu_state == "ok":
            self.menu_state = "dim_out_1"
        if self.menu_state == "dim_out_1":
            if not self.dimmer:
                self.dimmer = pygame.Surface(display.get_surface().get_size())
                self.dimmer.fill((0, 0, 0))
            self.dimmer.set_alpha(self.dim)
            self.dim += 1
            viewport.blit(self.dimmer, (0, 0))
            if self.dim > 30:
                self.menu_state = "dim_in_zoom"
                self.dimmer = None
        if self.menu_state in ("dim_in_zoom", "wait"):
            if not self.dimmer:
                self.dimmer = pygame.Surface(display.get_surface().get_size())
            scaled = transform.scale(self.screen, self.zoom_size)
            viewport.blit(scaled,
                          ((-scaled.get_width() + VWIDTH)/2,
                           (-scaled.get_height() + VHEIGHT)/2))

            self.draw_score(viewport)
            self.draw_highscores(viewport)
            self.scores.add_score(self.points)

            if self.menu_state == "dim_in_zoom":
                self.dimmer.set_alpha(self.dim)
                self.dim -= 1
                self.zoom_size[0] -= 10
                self.zoom_size[1] -= 10

            viewport.blit(self.dimmer, (0, 0))
            if self.dim < 4:
                self.menu_state = "wait"
开发者ID:bluepeppers,项目名称:me,代码行数:35,代码来源:me.py

示例2: after_turn

 def after_turn(self):
     if self.f.winner():
         out = self.handler.onWin()
         s = smallfont.render(out, True, Color('#000000'), Color('#ffffff'))
         sw, sh = s.get_size()
         display.get_surface().blit(s, (((self.xsize * self.fieldsize) - sw) / 2, 0))
         display.update()
         while pygame.event.wait().type != QUIT:
             pass
         return True
     self.player = self.newplayer()
     self.handler.player = self.player
开发者ID:jplitza,项目名称:natocubes,代码行数:12,代码来源:NATOcubes.py

示例3: update

    def update(self, plitki=[]):
        if len(plitki) > 1:
            for pl in plitki:
                if self != pl:
                    if collide_rect(self, pl):
                        if self.rect.x < pl.rect.x:
                            self.rect.x -= 1
                            pl.rect.x += 1
                        elif self.rect.x > pl.rect.x:
                            self.rect.x += 1
                            pl.rect.x -= 1
                        if self.rect.y < pl.rect.y:
                            self.rect.y -= 1
                            pl.rect.y += 1
                        elif self.rect.y > pl.rect.y:
                            self.rect.y += 1
                            pl.rect.y -= 1
        surf = get_surface()
        if self.rect.x <= 0:
            self.rect.x += 1
        if self.rect.y <= 0:
            self.rect.y += 1
        if self.rect.x+self.rect.w >= surf.get_width():
            self.rect.x -= 1
        if self.rect.y+self.rect.h >= surf.get_height():
            self.rect.y -= 1

        if self.mouse_on_button():
            self.image.fill((255-self.color[0], 255-self.color[1], 255-self.color[2]))
            rect(self.image, (125, 125, 125), (0, 0, self.rect.width, self.rect.height), 1)
            self.image.blit(self.font.render(self.text, 1, self.color), (3, 3))
        else:
            self.image.fill(self.color)
            rect(self.image, (255, 255, 255), (0, 0, self.rect.width, self.rect.height), 1)
            self.image.blit(self.font.render(self.text, 1, (255-self.color[0], 255-self.color[1], 255-self.color[2])), (3, 3))
开发者ID:LoganStalker,项目名称:second_season,代码行数:35,代码来源:Buttons.py

示例4: pause

def pause(display):
    global main_score
    screen = display.get_surface()

    hsfont = font.Font(FONT, 100)
    ysfont = font.Font(FONT,100)
    hs = hsfont.render("HIGH SCORE :-->" + str(highscore/2), True, HIGHSCORE_COLOR)
    
    y_score = ysfont.render("YOUR SCORE :-->"+str(main_score/2), True, Y_SCORE_COLOR)
    
    main_score = 0
    #score = 0

  
    pause_img=image.load('pause.png').convert_alpha()
    pause_img=transform.scale(pause_img, (1200, 700)) 
 
    screen.blit(pause_img, (0, 0,))
    screen.blit(hs, (200, 60))
    screen.blit(y_score, (200, 200))
    display.flip()

    while True:
        for i in event.get():
            if i.type == MOUSEBUTTONDOWN or i.type == KEYDOWN:
                    return main()
开发者ID:abhishek3022,项目名称:Touch-free-flappy-bird-game,代码行数:26,代码来源:main.py

示例5: __init__

 def __init__(self):
     scrsize = self.w, self.h = display.get_surface().get_size()
     Surface.__init__(self, scrsize)
     self.foo = 0
     self.l0 = []
     self.l1 = []
     self.l2 = []
开发者ID:strin,项目名称:curriculum-deep-RL,代码行数:7,代码来源:starsfield.py

示例6: build

def build(settings):  
	pygame.init()
	fullscreen = True
	  
	if fullscreen:
		depth = 0
		flags = FULLSCREEN | HWSURFACE | DOUBLEBUF
	else:
		depth = 16
		flags = SWSURFACE | DOUBLEBUF
	  
	modes = display.list_modes(depth, flags)
	if fullscreen:
		if modes == -1:  # Welcome to exceptionlessland
			raise SystemExit("Failed to initialize display")
		else:
			mode = max(modes)
	else:
		mode = (settings.screen_width,settings.screen_height)
	  
	display.set_mode(mode, flags)
	#print(modes)
	#print(mode[0])
	#print(mode[1])
	return (display.get_surface(),mode[0],mode[1])
开发者ID:TinyFrank,项目名称:FakeIt,代码行数:25,代码来源:display.py

示例7: get_center

def get_center(screen, new_img):
    "find out where the center of the screen is"
    screen = get_surface()
    screen_center = screen.get_rect().center
    rect = new_img.get_rect()
    rect.center = screen_center
    return rect
开发者ID:rkulla,项目名称:imgv,代码行数:7,代码来源:img_screen.py

示例8: __init__

 def __init__(self):
     
     screen_w, screen_h = display.get_surface().get_size()
     self.health_bar = Bar(
             Rect(10, screen_h - 20, 300, 10), 100, (200, 0, 0))
     self.name_plates = NamePlates()
     self.player_name = ""
开发者ID:Daladevelop,项目名称:havencore,代码行数:7,代码来源:hud.py

示例9: draw

    def draw(self):
        # Desktop draws directly on screen

        # Supposing method update was called before this, all widgets have redrawn their
        # private surfaces so they are ready to be drawn on the screen.
        for widget in self.widgets:
            widget.draw(display.get_surface())
开发者ID:wjwwood,项目名称:Auburn-Lunar-Excavator,代码行数:7,代码来源:gui.py

示例10: runtrial

 def runtrial(self):
     surface = display.get_surface()
     surface.fill((255,255,255))
     surface.blit(self.image,TOPLEFT)
     display.flip()
     self.sound.play()
     time.sleep(ST_LENGTH)
     surface.blit(self.fill,TOPLEFT)
     display.flip()
     time.sleep(TB_LENGTH)
     keypresses = []
     for e in event.get(KEYDOWN):
         keypresses += [e.dict['unicode']]
     if SPACE in keypresses:
         return None
     if unicode(KEYLEFT) in keypresses:
         if self.trgtimg:
             #print "user hit key \""+ KEYLEFT +"\" correctly"
             self.result[0] = True
         else:
             #print "user hit key \""+ KEYLEFT +"\" incorrectly"
             self.result[0] = False
     if unicode(KEYRIGHT) in keypresses:
         if self.trgtsnd:
             #print "user hit key \""+ KEYRIGHT +"\" correctly"
             self.result[1] = True
         else:
             #print "user hit key \""+ KEYRIGHT +"\" incorrectly"
             self.result[1] = False
     return True
开发者ID:sfavors3,项目名称:MindMixer,代码行数:30,代码来源:mindmixer.py

示例11: fit_image

def fit_image(img):
    "resize the image to fit the imgv window"
    screen = get_surface()
    gl.SCALE_UP = 0
    if gl.REAL_WIDTH > gl.REAL_HEIGHT:
        r = float(gl.REAL_WIDTH) / float(gl.REAL_HEIGHT)
        new_width = screen.get_width()
        new_height = int(new_width / r)
        scale_val = new_width, new_height
        img = scale(img, scale_val)
        gl.SHRUNK = 1
    elif gl.REAL_WIDTH < gl.REAL_HEIGHT:
        r = float(gl.REAL_HEIGHT) / float(gl.REAL_WIDTH)
        new_height = screen.get_height()
        new_width = int(new_height / r)
        scale_val = new_width, new_height
        img = scale(img, scale_val)
        gl.SHRUNK = 1
    elif gl.REAL_WIDTH == gl.REAL_HEIGHT:
        r = float(gl.REAL_WIDTH) / float(gl.REAL_HEIGHT)
        new_height = screen.get_height()
        new_width = screen.get_width()
        if new_height > new_width:
            scale_val = int(new_width / r), int(new_width / r)
        elif new_width > new_height:
            scale_val = int(new_height / r), int(new_height / r)
        else:
            scale_val = new_width, new_height
        img = scale(img, scale_val)
    else:
        new_height = new_width = screen.get_width()
        scale_val = new_width, new_height
        img = scale(img, scale_val)
    return img
开发者ID:rkulla,项目名称:imgv,代码行数:34,代码来源:load_img.py

示例12: command_fullscreen

def command_fullscreen():
    "Toggle between full screen and last screen resolution"
    screen = get_surface()
    wait_cursor()
    if not toggle_fullscreen():
        try:
            if gl.FULLSCREEN_SPECIAL:
                screen_res = screen.get_size()
            else:
                screen_res = screen.get_size()
                gl.MAX_SCREEN_FILES = gl.MAX_SF["%sx%s" % (
                    screen_res[0], screen_res[1])]

            if not gl.TOGGLE_FULLSCREEN_SET:  # go into fullscreen mode
                gl.BEFORE_WINSIZE = screen.get_size()
                screen = set_mode(screen_res, screen.get_flags(
                ) ^ FULLSCREEN, screen.get_bitsize())
            else:  # returning from fullscreen. Go back to last screen size:
                set_mode(gl.BEFORE_WINSIZE, screen.get_flags(
                ) ^ FULLSCREEN, screen.get_bitsize())
                screen = set_mode(
                    gl.BEFORE_WINSIZE, RESIZABLE)  # make resizeable
            my_toggle_fullscreen()
        except:
            print "Couldn't toggle fullscreen. Resolution probably not supported by your video card."
    return screen
开发者ID:rkulla,项目名称:imgv,代码行数:26,代码来源:res.py

示例13: run

    def run(self):

        window = display.get_surface()

        for evt in event.get():
            if evt.type == pygame.QUIT:
                self.quit()
            elif evt.type == pygame.MOUSEMOTION:
                self.processMouseMotion(evt.pos)

            elif evt.type == pygame.KEYDOWN:
                self.processKeyDown(evt.key)

            elif evt.type == pygame.MOUSEBUTTONDOWN:
                self.processMouseButtonDown(evt.pos)

            elif evt.type == pygame.MOUSEBUTTONUP:
                self.processMouseButtonUp(evt.pos)

        window.fill(self.aColor)

        # self.testObj.rect.x = self.mouseX
        # self.testObj.rect.y = self.mouseY
        # self.activeSprites.draw(window)

        self.activeState.update(self.Clock.get_time())
        self.activeState.activeSprites.draw(window)
        if len(self.activeState.pts) > 1:
            draw.lines(window, (255, 0, 255), False, self.activeState.pts, 3)

        self.Clock.tick(30)
        display.flip()
        self.run()
开发者ID:Berulacks,项目名称:ethosgame,代码行数:33,代码来源:game.py

示例14: paint_screen

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

示例15: __init__

    def __init__(self, game, player, zoom):
        self.game = game
        self._player = player
        self.zoom = zoom
        
        self.definetiles()

        self.makescreen(display.get_surface().get_size())
开发者ID:tps12,项目名称:Dorftris,代码行数:8,代码来源:rendering.py


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