pygame-surface

can't blit a surface with its lines on display

can't blit a surface with its lines on display Question: I’m trying to draw a line on a surface that I then blit on the display. When I’m doing so, only the surface appeares while the line is not drawned. The code I wrote is import pygame as pg import numpy as np pg.init() # …

Total answers: 1

How do I create an extendable bar sprite in PyGame?

How do I create an extendable bar sprite in PyGame? Question: I want to use the following asset in my game: It has specific pixelated borders and corners. So I want it to scale "extending" the inner part of the asset by repeating it until it matches the desired size. So I can render something …

Total answers: 2

PyGame colliders don't scale with window

PyGame colliders don't scale with window Question: I think I should point out that I’m a beginner with PyGame. I have made a program that displays some simple graphics on the screen using PyGame. It blits every graphic on a dummy surface and the dummy surface gets scaled and blit to a ‘real’ surface that …

Total answers: 1

Pygame sprite group won't draw because of error: Source objects must be a suface

Pygame sprite group won't draw because of error: Source objects must be a suface Question: im having a problem with my 2D Platformer game and when trying to display sprite group, an error message appears saying: Pygame: TypeError: Source objects must be a surface, The problem seems to be around the coins sprite group when …

Total answers: 1

Selectively reset the color of the surface after blitting PyGame

Selectively reset the color of the surface after blitting PyGame Question: I have two green surfaces s1 = Surface((100, 100)) s2 = Surface((100, 100)) s1.fill((0, 255, 0)) s2.fill((0, 255, 0)) Then i blit them on main surface with beautiful background screen.blit(image.load("ocean.png").convert_alpha(), (0, 0)) screen.blit(s1, (0, 100)) screen.blit(s2, (200, 100)) Result: Question: How can i selectively …

Total answers: 1

Pygame Memory Card with list of images

Pygame Memory Card with list of images Question: I’m trying to build a memory card game using pygame where I list the cards that are a match: # Load the images image1 = pygame.image.load("1.png") image2 = pygame.image.load("2.png") image3 = pygame.image.load("3.png") image4 = pygame.image.load("4.png") # Create a list of image pairs images = [[image1, image2], [image3, …

Total answers: 1

How do you clip a circle (or any non-Rect) from an image in pygame?

How do you clip a circle (or any non-Rect) from an image in pygame? Question: I am using Pygame and have an image. I can clip a rectangle from it: image = pygame.transform.scale(pygame.image.load(‘example.png’), (32, 32)) handle_surface = image.copy() handle_surface.set_clip(pygame.Rect(0, 0, 32, 16)) clipped_image = surface.subsurface(handle_surface.get_clip()) I have tried to use subsurface by passing a Surface: …

Total answers: 1

Sprite not being drawn

Sprite not being drawn Question: I am a beginner programmer practicing with Python. I am trying to make a simple game, what I have so far is just adding the character sprite onto the map. What I’m trying to do is when no keys are being pressed, that the character sprite continuously switches between two …

Total answers: 1

Sprite shadow changing to full black

Sprite shadow changing to full black Question: player.png shadow comparison The shadows are different when I blit the player image to a surface and then loading that surface to the display vs loading the entire image on the display import pygame pygame.init() display = pygame.display.set_mode((1280, 736)) display.fill(‘#555358’) clock = pygame.time.Clock() if __name__ == ‘__main__’: image_1 …

Total answers: 1