Pygame + Powerpoint = Pygpoint.
This new version fits the screen to images, making the code more “general use”
# load a spreadsheet
import pygame
import sys
from glob import glob
def init():
"Load images and set the screen to fit them"
global images
global screen
global clock
images = [pygame.image.load(png) for png in glob("images01\\*.png")]
width = images[0].get_rect().width
height = images[0].get_rect().height
screen = pygame.display.set_mode((width, height))
clock = pygame.time.Clock()
init()
counter = 0
loop = 1
while loop:
for event in pygame.event.get():
if event.type == pygame.QUIT:
loop = 0
if event.type == pygame.KEYDOWN:
if counter < 7:
counter += 1
else:
counter = 0
screen.fill((0,0,0))
screen.blit(images[counter], (0, 0))
pygame.display.flip()
clock.tick(10)
pygame.quit()
sys.exit()
Subscribe to the newsletter for updates
Tkinter templatesTwitter: @pythonprogrammi - python_pygame
Claude's Games
1. Memory gameVideos
Speech recognition gamePygame's Platform Game