The first video is the first of the series by Coding with Russ about one of the favourite topic about videogames: platform games. Russ has made a great kob here for our favourite module ‘pygame’.
Lets summarize the first tutorial




Load the image for the player




If we want to scale it, we need to multiply the width and height of the image for… 3, for example (scale = 3)





See you for the next episode. The repository is here.
import pygame
pygame.init()
SCREEN_WIDTH = 800
SCREEN_HEIGHT = int(SCREEN_WIDTH * 0.8)
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption('Shooter')
class Soldier(pygame.sprite.Sprite):
def __init__(self, x, y, scale):
pygame.sprite.Sprite.__init__(self)
img = pygame.image.load('img/player/Idle/0.png')
self.image = pygame.transform.scale(img, (int(img.get_width() * scale), int(img.get_height() * scale)))
self.rect = self.image.get_rect()
self.rect.center = (x, y)
def draw(self):
screen.blit(self.image, self.rect)
player = Soldier(200, 200, 3)
player2 = Soldier(400, 200, 3)
run = True
while run:
player.draw()
player2.draw()
for event in pygame.event.get():
#quit game
if event.type == pygame.QUIT:
run = False
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