Updating the pygame window attributes
There are a few attributes in case of
pygamewindow that we can update. Let’s dive a little into so that we know about all the options that we have.
Update the titleThe first up in the list is the title of the
pygamewindow. We are going to replace that with the name of our game, PPO snake.
Updating the icon
You can any
32X32 pximage. I took a random snake image from flaticon. For updating the icon, use the following code.
icon = pygame.image.load("assets/snakes.png") pygame.display.set_icon(icon)
Updating the background colorFor updating the background color of the
pygamewindow you can write the following code in the main while loop.
It is very important to update the display after we change the color. Otherwise, the change won’t reflect. The value inside the
screen.fill((100, 100, 255)) pygame.display.update()
fillfunction is the RGB value and you can use any website like this and add a color of your choice.
Please share your Feedback:
Did you enjoy reading or think it can be improved? Don’t forget to leave your thoughts in the comments section below! If you liked this article, please share it with your friends, and read a few more!