當前位置: 首頁>>代碼示例>>Python>>正文


Python Background.render方法代碼示例

本文整理匯總了Python中background.Background.render方法的典型用法代碼示例。如果您正苦於以下問題:Python Background.render方法的具體用法?Python Background.render怎麽用?Python Background.render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在background.Background的用法示例。


在下文中一共展示了Background.render方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: deque

# 需要導入模塊: from background import Background [as 別名]
# 或者: from background.Background import render [as 別名]
    # player
    player = None
    # put desks, garbage cans, etc in here
    env_obj_col = deque()
    # put the ai stuff in here, but not player
    ai_col = deque()
    # rectangles that ai are only allowed to be in (e.g. for movement)
    navmesh_col = deque()

    # init rendering
    # Queue of rects specifying areas of display to update
    update_queue = deque()

    background = Background(WINDOW_WIDTH, WINDOW_HEIGHT, WHITE)
    background.render(screen, update_queue)

    # level
    load_level("level.txt")

    # Force update display (generally handled at end of main loop below)
    update_display(update_queue)

    while running:
        # input loop
        for event in pygame.event.get():
            if event.type == KEYUP:
                if event.key == K_ESCAPE:
                    running = False
            elif event.type == QUIT:
                running = False
開發者ID:Roolymoo,項目名稱:fantasygame,代碼行數:32,代碼來源:main.py

示例2: deque

# 需要導入模塊: from background import Background [as 別名]
# 或者: from background.Background import render [as 別名]
    COMP_SAD_N = "computer_sad.png"
    COMP_HAP_N = "computer_happy.png"
    MAN_STAND_N = "man_standing.png"

    # Create the screen
    screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))

    env_obj_list = deque()

    monster_list = deque()

    # init rendering
    update_queue = deque() # Queue of rects specifying areas of display to update

    background = Background(WINDOW_WIDTH, WINDOW_HEIGHT, GREY)
    background.render(screen, update_queue)

    # draw a bunch of garbage cans (debug)
    gbg_can_size = IMG_SIZES["garbage_can"]

    x_coord = TILE_SIZE * 3
    while x_coord < TILE_SIZE * 10:
        y_coord = TILE_SIZE * 3
        while y_coord < WINDOW_HEIGHT:
            gbg_can = Obj(x_coord, y_coord, gbg_can_size[0], gbg_can_size[1])

            gbg_can.img = load_img(GBG_CAN_N)
            gbg_can.render(screen, update_queue)

            env_obj_list.append(gbg_can)
開發者ID:Roolymoo,項目名稱:comprev,代碼行數:32,代碼來源:main.py

示例3: __init__

# 需要導入模塊: from background import Background [as 別名]
# 或者: from background.Background import render [as 別名]

#.........這裏部分代碼省略.........
        if abs(self.player1.Y - self.player2.Y) >= self.screenSize[1]:
            self.player2.X = self.player1.X
            self.player2.Y = self.player1.Y
        #"""   

        #######PAUSA(con joystick)##################################
        button = self.joystickList[0].get_button(8) #or self.joystickList[1].get_button(7)##
        #button2 = self.joystickList[1].get_button(9) #or self.joystickList[1].get_button(7)##
        if button:
            self.pauseGame = True
        pressedKey = pygame.key.get_pressed()
        if pressedKey[K_TAB]:
            self.pauseGame = True
        #if button2:
        #    self.gameOver = True


        ###########CAMBIO_DE_ETAPA##################################
        if self.player1.exitStage or self.player2.exitStage:
            self.player1.exitStage = False
            self.player2.exitStage = False
            self.background.changeBackground()
            self.player1.X = self.background.levelMaker.startXPosition
            self.player1.Y = self.background.levelMaker.startYPosition
            self.player2.X = self.background.levelMaker.startXPosition 
            self.player2.Y = self.background.levelMaker.startYPosition

        #################GAME_OVER##################################
        if self.player1.dead or self.player2.dead:
            self.gameOver = True
                 

    # Dibuja en pantalla los sprites y el escenario
    def render(self):
        
        # Instancia de la ventana de pygame
        screen = pygame.display.get_surface()

        # Render a las instancias del nivel
        self.background.render()
        self.player2.render()   #-----------------#
        self.player1.render()
        for torreta in self.background.levelMaker.torretas:
            torreta.render()

        # Brujula que apunta a otro player
        if self.horizontalCompassNeeded or self.P1horizontalCompassNeeded:
            if self.player2.Y <= -50 or self.player1.Y <= -50:
                self.compass.image = self.compassImageUp
                if self.player2.Y <= -50:
                    screen.blit(self.compass.image, (self.player2.X, 0))
                else:
                    screen.blit(self.compass.image, (self.player1.X, 0))
            if self.player2.Y >= self.screenSize[1] or self.player1.Y >= self.screenSize[1]:
                self.compass.image = self.compassImageDown
                if self.player2.Y >= self.screenSize[1]:
                    screen.blit(self.compass.image, (self.player2.X, self.screenSize[1] - 15))
                else:
                    screen.blit(self.compass.image, (self.player1.X, self.screenSize[1] - 15))
        if self.verticalCompassNeeded:
            if self.player2.X <= -50:
                self.compass.image = self.compassImageLeft
                screen.blit(self.compass.image, (0, self.player2.Y))
            if self.player2.X >= self.screenSize[0]:
                self.compass.image = self.compassImageRight
                screen.blit(self.compass.image, ((self.screenSize[0] - 15), self.player2.Y))
開發者ID:Vingell,項目名稱:TPD-Arcade,代碼行數:70,代碼來源:level.py

示例4: __init__

# 需要導入模塊: from background import Background [as 別名]
# 或者: from background.Background import render [as 別名]

#.........這裏部分代碼省略.........
            self.player2.X = self.player1.X
            self.player2.Y = self.player1.Y
        if abs(self.player1.Y - self.player2.Y) >= self.screenSize[1]:
            self.player2.X = self.player1.X
            self.player2.Y = self.player1.Y
        #"""   


        ###########CAMBIO_DE_ETAPA##################################
        if self.player1.exitStage or self.player2.exitStage:
            self.player1.exitStage = False
            self.player2.exitStage = False

            self.background.changeBackground()

            self.backgroundImage = self.container.imageDictionary[self.background.backgroundKey]
            self.backgroundImage = pygame.transform.scale(self.backgroundImage, (self.screenSize[0], self.screenSize[1]))
            
            self.player1.X = self.background.levelMaker.startXPosition
            self.player1.Y = self.background.levelMaker.startYPosition
            self.player2.X = self.background.levelMaker.startXPosition 
            self.player2.Y = self.background.levelMaker.startYPosition

        #################GAME_OVER##################################
        if self.player1.dead or self.player2.dead:
            self.gameOver = True
            if self.player1.dead:
                self.deadMessage = self.player1.deadMessage
            else:
                self.deadMessage = self.player2.deadMessage
                 

    # Dibuja en pantalla los sprites y el escenario
    def render(self):
        
        # Instancia de la ventana de pygame
        screen = pygame.display.get_surface()

        # Render a las instancias del nivel
        screen.blit(self.backgroundImage, (0,0))
        
        self.player1.render()   
        self.player2.render()
        self.background.render()
        for torreta in self.background.levelMaker.torretas:
            torreta.render()

        # Brujula que apunta a otro player
        if self.horizontalCompassNeeded or self.P1horizontalCompassNeeded:
            if self.player2.Y <= -50 or self.player1.Y <= -50:
                self.compass.image = self.compassImageUp
                if self.player2.Y <= -50:
                    screen.blit(self.compass.image, (self.player2.X, 0))
                else:
                    screen.blit(self.compass.image, (self.player1.X, 0))
            if self.player2.Y >= self.screenSize[1] or self.player1.Y >= self.screenSize[1]:
                self.compass.image = self.compassImageDown
                if self.player2.Y >= self.screenSize[1]:
                    screen.blit(self.compass.image, (self.player2.X, self.screenSize[1] - 15))
                else:
                    screen.blit(self.compass.image, (self.player1.X, self.screenSize[1] - 15))
        if self.verticalCompassNeeded:
            if self.player2.X <= -50:
                self.compass.image = self.compassImageLeft
                screen.blit(self.compass.image, (0, self.player2.Y))
            if self.player2.X >= self.screenSize[0]:
開發者ID:MapacheOculto,項目名稱:TPD-Arcade,代碼行數:70,代碼來源:level.py


注:本文中的background.Background.render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。