pygame

How to scale multiple images with a for loop?

How to scale multiple images with a for loop? Question: I’m trying to use a for-loop to iterate through a list of self classes. I want to give each one the same scale. def __init__(self): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("Migue/m_normal.png") self.quieto = pygame.image.load("Migue/m_normal.png") self.andando = pygame.image.load("Migue/m_andando_normal.png") self.image = pygame.transform.scale(self.image, sizenorm) states = [self.quieto, self.andando] for i …

Total answers: 1

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

how do I draw this rect?

how do I draw this rect? Question: I m having trouble with function advanced_health in class Player for some reason it doesnt work when reducing the health it should draw an orange rect but it doesnt draw anything but it does draw the health when adding health pygame.draw.rect(screen,transition_color,transition_bar) How do I fix this? import pygame, …

Total answers: 1

How can I check collisions of 2 sprites groups?

How can I check collisions of 2 sprites groups? Question: How do I check the collisions between the bullet_grou and the enemy_group and if they collide I want them do disappear. I have looked at few simular questions but none of them helped me. Thenks for all the help. This game is supposed to be …

Total answers: 1

Problem with enemy movement towards player in pygame library

Problem with enemy movement towards player in pygame library Question: I ran into a problem with the pygame library while building my app. A part of my code is as follows: at the beginning of the class in the init method I create my enemies. self.create_enemy And then, that method is like this def create_enemy(self): …

Total answers: 2

Pong game, but the ball goes out of the window

Pong game, but the ball goes out of the window Question: I coded a Pong game but the ball goes out of the window. import pygame pygame.init() WIDTH, HEIGHT = 900, 500 WIN = pygame.display.set_mode((WIDTH, HEIGHT)) #Colors WHITE = (255, 255, 255) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) RED = (255, …

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

How can i render non rectangular part of an image?

How can i render non rectangular part of an image? Question: I’m learning how to create a multiplayer game with pygame by recreating Among-us. I’m currently trying to recreate the vision system. To make sure that the vision is blocked by walls, i’ve seen that a simple method is to place points at each corner …

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

can't get counter to move across a board anymore

can't get counter to move across a board anymore Question: I’m creating a board game and i’m in the initial stages of displaying the board and getting the counter to move across the squares. The code to get the counter to move worked, but I had to change where it was because the square colours …

Total answers: 1