Let’s start a serie of tutorial about Pygame. Ready? Go!
In this first part we will show:
- how to create a window
- how to create the main screen surface
- ho to display a square surface on the screen
The code of Pygame tutorial 1 – window and surfaces
import pygame
pygame.init()
screen = pygame.display.set_mode((400, 600))
square = pygame.Surface((20, 20))
square.fill((255, 0, 0))
while True:
screen.blit(square, (100, 100))
if pygame.event.get(pygame.QUIT):
break
pygame.display.update()
pygame.quit()
Subscribe to the newsletter for updates
Tkinter templatesTwitter: @pythonprogrammi - python_pygame
Claude's Games
1. Memory gameVideos
Speech recognition gamePygame's Platform Game