Updating the pygame window attributes
There are a few attributes in case of
pygame
window that we can update. Let’s dive a little into so that we know about all the options that we have.
Update the title
The first up in the list is the title of thepygame
window. We are going to replace that with the name of our game, PPO snake.
pygame.display.set_caption("PPO snake")
Updating the icon
We can add an image as the icon of the game. I am going to add the image to a newassets
directory.
mkdir assets
32X32 px
image. 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 color
For updating the background color of thepygame
window you can write the following code in the main while loop.
screen.fill((100, 100, 255))
pygame.display.update()
fill
function is the RGB value and you can use any website like this and add a color of your choice.
About Author
Ranvir Singh
Greetings! Ranvir is an Engineering professional with 3+ years of experience in Software development.
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!