PyGame Tutorial – Giving Title

In this Pygame Tutorial we want to learn about Giving Title to your Pygame game, if you are creating a game with Pygame, one of the important things you want to do is give it a title. title of your game will be the first thing players see when they start the game, so it is essential to make it nice and descriptive title. in this article we want to learn how to give your Pygame game a title using pygame.display.set_caption() function.

 

 

 

First of all, you need to importPygame module and initialize it with the pygame.init() function.

 

 

 

After that the Pygame is initialized you can set caption or title of your game display window using pygame.display.set_caption() function. this function takes string as an argument, which will be the title of your game. for example:

 

 

 

After setting the caption of your game, you need to update Pygame display for the changes to take effect. you can do this with pygame.display.update() function.

 

 

 

This is the complete code for this article

This code initializes Pygame and sets dimensions of the display window. after that it sets the title of the display window using pygame.display.set_caption(), and updates the display using pygame.display.update(). and finally the code enters a game loop that continually updates the display until the user closes the window.

 

 

 

 

Run the complete code and this will be the result

PyGame Tutorial - Giving Title
PyGame Tutorial – Giving Title

Subscribe and Get Free Video Courses & Articles in your Email

 

Leave a Comment

Share via
Copy link
Powered by Social Snap
×