In this output, we can see the new window appears and the circle with red color appears on the pygame window. () is used to update the content of the display to the screen.To draw the circle of red color we have used the “(200, 0, 0)” parameter, “(250, 250)” is used for specifying the center coordinates of the circle, and “80” is the radius of a circle to draw in pixels.Now, scr.fill((255, 255, 255)) is used to fill the background with white.Here, while is used to run until the user asks to quit.The pygame.init() is used to initialize all the required modules of the pygame. Let’s see how to draw a circle using python pygame. How to resize a window in python pygame How to draw a circle using python pygame In this output, we can see the new window appears and we can resize the window accordingly. Then run the pygame using while, and to quit pygame after closing window we have used pygame.quit()._caption(‘Resizable Window’) is used to set the title according to the user choice.To form a screen we will use _mode() method with resizing using pygame.RESIZABLE.Let’s see how to resize a window in python pygame. Output: 1366 768 How to resize a window in python pygame In the below output, you can see the size of python pygame window. Here, () is used to quit pygame, and print(x, y) is used for printing the value.To get the size of the screen we will use the “scr.get_size()” method.scr = _mode() is used to form screen using this method.Let’s see how to get the size of python pygame window. How to put the screen in a specific spot in python pygame How to get the size of Python pygame window In this output, we can see that the new window appear as an output with a caption. It is important to call this function in order to make any updates that we will make on the game screen. pygame.QUIT is used to terminate the event when we click the close button of the window.It is important to call, and if we do not call, then the window message will start to pile up, and it will become unresponsive. So, we will use “done = True” to exits out of the window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |