How to use the pygame.display.update function in pygame

To help you get started, we’ve selected a few pygame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Bloodevil / sony_camera_api / examples / pygameLiveView.py View on Github external
# Corners
                   pygame.draw.lines(screen, 0x00ff00, False, \
                      [(left + 10, top), (left, top), (left, top + 10)], 2)
                   pygame.draw.lines(screen, 0x00ff00, False, \
                      [(right - 10, top), (right, top), (right, top + 10)], 2)
                   pygame.draw.lines(screen, 0x00ff00, False, \
                      [(left + 10, bottom), (left, bottom), (left, bottom - 10)], 2)
                   pygame.draw.lines(screen, 0x00ff00, False, \
                      [(right - 10, bottom), (right, bottom), (right, bottom - 10)], 2)
          else:
             screen.blit(incoming_image,(0,0))
       elif header:
           # Only blit if it's a new image
           screen.blit(incoming_image,(0,0))

       pygame.display.update((origin_x, origin_y, width, height))

# clean up
pygame.quit()
github Mekire / pygame-textbox / example.py View on Github external
def main_loop(self):
        while not self.done:
            self.event_loop()
            self.input.update()
            self.screen.fill(self.color)
            self.input.draw(self.screen)
            self.screen.blit(*self.prompt)
            pg.display.update()
            self.clock.tick(self.fps)
github chncyhn / flappybird-qlearning-bot / src / flappy.py View on Github external
upperPipes.pop(0)
            lowerPipes.pop(0)

        # draw sprites
        SCREEN.blit(IMAGES["background"], (0, 0))

        for uPipe, lPipe in zip(upperPipes, lowerPipes):
            SCREEN.blit(IMAGES["pipe"][0], (uPipe["x"], uPipe["y"]))
            SCREEN.blit(IMAGES["pipe"][1], (lPipe["x"], lPipe["y"]))

        SCREEN.blit(IMAGES["base"], (basex, BASEY))
        # print score so player overlaps the score
        showScore(score)
        SCREEN.blit(IMAGES["player"][playerIndex], (playerx, playery))

        pygame.display.update()
        FPSCLOCK.tick(FPS)
github koduj-z-klasa / python101 / docs / pong / pong_z3.py View on Github external
def draw(self, *args):
        """
        Rysuje okno gry

        :param args: lista obiektów do narysowania
        """
        background = (230, 255, 255)
        self.surface.fill(background)
        for drawable in args:
            drawable.draw_on(self.surface)

        # dopiero w tym miejscu następuje fatyczne rysowanie
        # w oknie gry, wcześniej tylko ustalaliśmy co i jak ma zostać narysowane
        pygame.display.update()
github YuriyGuts / snake-ai-reinforcement / snakeai / gui / pygame.py View on Github external
if not is_human_agent:
                    action = self.agent.act(timestep_result.observation, timestep_result.reward)

                self.env.choose_action(action)
                timestep_result = self.env.timestep()

                if timestep_result.is_episode_end:
                    self.agent.end_episode()
                    running = False

            # Render.
            self.render()
            score = self.env.snake.length - self.env.initial_snake_length
            pygame.display.set_caption(f'Snake  [Score: {score:02d}]')
            pygame.display.update()
            self.fps_clock.tick(self.FPS_LIMIT)
github buckyroberts / Source-Code-from-Tutorials / Pygame / 59_PythonGameDevelopment.py View on Github external
FPS = 15

    mainTankX = display_width * 0.9
    mainTankY = display_height * 0.9
    tankMove = 0

    currentTurPos = 0
    changeTur = 0
    
    while not gameExit:
        
        if gameOver == True:
            #gameDisplay.fill(white)
            message_to_screen("Game Over",red,-50,size="large")
            message_to_screen("Press C to play again or Q to exit",black,50)
            pygame.display.update()
            while gameOver == True:
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        gameExit = True
                        gameOver = False

                    if event.type == pygame.KEYDOWN:
                        if event.key == pygame.K_c:
                            gameLoop()
                        elif event.key == pygame.K_q:
                            
                            gameExit = True
                            gameOver = False
github buckyroberts / Source-Code-from-Tutorials / Pygame / 71_PythonGameDevelopment.py View on Github external
startPoint = x,y

        colorChoices = [red, light_red, yellow, light_yellow]

        magnitude = 1

        while magnitude < 50:

            exploding_bit_x = x +random.randrange(-1*magnitude,magnitude)
            exploding_bit_y = y +random.randrange(-1*magnitude,magnitude)

            pygame.draw.circle(gameDisplay, colorChoices[random.randrange(0,4)], (exploding_bit_x,exploding_bit_y),random.randrange(1,5))
            magnitude += 1

            pygame.display.update()
            clock.tick(100)

        explode = False
github techwithtim / Pictonary-Livestream / client / game.py View on Github external
def draw(self):
        self.win.fill(self.BG)
        self.leaderboard.draw(self.win)
        self.top_bar.draw(self.win)
        self.board.draw(self.win)
        self.skip_button.draw(self.win)
        if self.drawing:
            self.bottom_bar.draw(self.win)
        self.chat.draw(self.win)
        pygame.display.update()
github mohitwildbeast / Gesture-Controlled-Snake-Game / SnakeGame.py View on Github external
newHead = {'x': wormCoords[HEAD]['x'], 'y': wormCoords[HEAD]['y'] - 1}
		elif direction == DOWN:
			newHead = {'x': wormCoords[HEAD]['x'], 'y': wormCoords[HEAD]['y'] + 1}
		elif direction == RIGHT:
			newHead = {'x': wormCoords[HEAD]['x'] + 1, 'y': wormCoords[HEAD]['y']}
		elif direction == LEFT:
			newHead = {'x': wormCoords[HEAD]['x'] - 1, 'y': wormCoords[HEAD]['y']}
		wormCoords.insert(0, newHead)

#Drawing the Screen
		SCREEN.fill(BGCOLOR)
		drawGrid()
		drawWorm(wormCoords)
		drawApple(apple)
		drawScore((len(wormCoords) - 3) * 10)
		pygame.display.update()
		CLOCK.tick(FPS)