Click here to Skip to main content
15,845,681 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
import pygame
import random
clock = pygame.time.Clock()

screen = pygame.display.set_mode((1000,600))
pygame.display.set_caption("Flappy bird")

bird_image = pygame.image.load("FLAPPY.png")
wall_image = pygame.image.load("ENEMY.png")
bird_image = pygame.transform.scale(bird_image, (80,60))
bird_rect = bird_image.get_rect() (300, 300)
bird_speed = 0
gravity = 0.5
jump = 1

wall_group = pygame.sprite.Group
spawn_wall_event = pygame.USEREVENT
pygame.time.set_timer(spawn_wall_event, 3000)

class Wall(pygame.sprite.Sprite):
    def __init__(self, pos, image ): 
          self.image = image
          self.rect = self.image.get_rect()
 = pos
    def update(self):

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
               running = False
        if event.type == spawn_wall_event:
            wall=Wall((650, random.randint(0, 20)), wall_image)
    keys = pygame.key.get_pressed()
    if keys[pygame.K_SPACE]:

    screen.blit(bird_image, bird_rect)


What I have tried:

I tried to run the code. But it gave me the error: AbstractGroup.draw() missing 1 required positional argument: 'surface'
Updated 16-Jul-23 3:04am
Richard MacCutchan 16-Jul-23 3:47am    
You need to check the documentation for the classes that you asre using. The error message should help to point you to the call that is failing. You can then trace through the code with the debugger to find out exactly what is missing.

We can't tell - we have no idea where in your code the error is occuring.

So start with the error message - it will tell you the file in which the error occurred and the line number it was found on. Most text / code editors use CTRL+G to go directly to a line number so it should be easy to find.

The use the python debugger to look at your code while it is running: pdb — The Python Debugger — Python 3.11.4 documentation[^]
Put a breakpoint on the line that you found gives the error, and look at all the variables involved.

Sorry, but we can't do that for you!
Share this answer
Look at the documentation at pygame.sprite.AbstractGroup[^]. The painting surface is the second parameter, the first being the this reference to the current object. So you just need to pass the correct reference in your call to:
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900