[Solved] How do i make a wall for breakout in pygame?

You can use bricks = pygame.sprite.Group() bricks.add( Bloque(0, 0) ) bricks.add( Bloque(100, 0) ) # etc. to keep bricks. And later you can use bricks.draw(screen) bricks.update() pygame.sprite.spritecollide(bola, bricks, dokill=True) Full working code import pygame import os import sys #— constants — (UPPER_CASE names) ANCHO = 768 LARGO = 480 DIRECCION = “imagenes” BLACK = ( … Read more

[Solved] Not sure why If Statement is not working. (Pygame)

Surfaces doesn’t have an object for retrieving the file name, but maybe you could use another variable to hold the file name? #load images bg_filename = “start.png” background = pygame.image.load(bg_filename) #keep looping through while 1: #clear the screen before drawing it again screen.fill(0) #draw the screen elements screen.blit(background, (0,0)) #update the screen pygame.display.flip() #loop through … Read more

[Solved] Efficient loading of Pygamescreens to 2D-lists

You can almost triple the speed by using pygame.surfarray. But I don’t thing you actually want to have a list of the pixels. Please post a new question with you underling problem, as @hop suggested. def load(screen): return pygame.surfarray.pixels2d(screen).tolist() solved Efficient loading of Pygamescreens to 2D-lists

[Solved] The same program again

Try changing: if x >= end: To: if x >= end and y <= end: Also, change: keepgoing == False To: keepgoing = False Also, consider changing: if x == end and y == end: To: if x >= end and y >= end: Note: You should probably use a nested for-loop and cycle through … Read more

[Solved] snake game: snake colliding with itself

In your code it looks as though you are checking if the head of the snake collide with itself, which will always return True. You need to individually check that the head of snake does not collide with any of it’s trailing segments: for segment in SnakeSegments[2:]: if pygame.sprite.collide_rect(h, segment): pass # collision detected, game-over … Read more