Skip to main content
Impoved the question and updated the code
Source Link
GospelBG
  • 73
  • 2
  • 14

I'm making my first game of Pygame. I'm going to create groups for themaking collisions but when I add an object to the group, I get an error in sprite.py in Pygame's files:(Pygame's Files)

What I'm doing wrongWhy I get this error?
There is a simplest way to make collisions?

There is my code (This file is imported from main.py, that's why things are missing in the code):

import pygame
from pygame.locals import *
import sys
import os
import time
from pygame.locals import *
width = 950
height = 500
SpikesGame = 1False
GameGameOver = False
keyboard = pygame.key.get_pressed()[K_UP]
def playmain():
    Game = True
    pygame.init()
    screen = pygame.display.set_mode((width, height))
    pygame.display.set_caption('Flappy Dog')
    background = pygame.image.load(os.path.join("Images", "Background_00.png")).convert()
    FlappyDog = pygame.image.load(os.path.join("Images", "Flappy.png")).convert_alpha()
    Play = pygame.image.load(os.path.join("Images", "Play.png")).convert_alpha()
    Dog0 = pygame.image.load(os.path.join("Images", "Dog0.png")).convert_alpha()
    Dog1 = pygame.image.load(os.path.join("Images", "Dog1.png")).convert_alpha()
    SpikeUp0 = pygame.image.load(os.path.join("Images", "SpikeUp0.png")).convert_alpha()
    SpikeUp1 = pygame.image.load(os.path.join("Images", "SpikeUp1.png")).convert_alpha()
    SpikeDown0 = pygame.image.load(os.path.join("Images", "SpikeDown0.png")).convert_alpha()
    SpikeDown1 = pygame.image.load(os.path.join("Images", "SpikeDown1.png")).convert_alpha()
    GameOver = pygame.image.load(os.path.join("Images", "Game-Over.png")).convert_alpha()
    Replay = pygame.image.load(os.path.join("Images", "Replay.png")).convert_alpha()
    Bone = pygame.image.load(os.path.join("Images", "Bone.png")).convert_alpha()
    
    bonesSpikesGame = pygameTrue
    Dog1_pos_x = 100
    Dog1_pos_y = 100
    screen.spriteblit(background, (0, 0))
    screen.Groupblit(FlappyDog, (0, 0))
    bonesSpikesscreen.addblit(Bone, (SpikeDown0550, 100))
    bonesSpikesscreen.addblit(Play, (SpikeUp0600, 350))
    bonesSpikesscreen.addblit(Dog0, (Bone5, 240))
    Dogbones = pygame.sprite.Group()
    Dogbones.add(Dog1Bone) # <-- Error here
    CrashDog = pygame.sprite.spritecollideGroup()
    Dog,.add(Dog1)
 bonesSpikes, True  pygame.display.update()
    
    Dog1_pos_x 
 = 100  while True:
    Dog1_pos_y = 100  if GameOver == true:
            screen.blit(background, (0, 0))
            screen.blit(FlappyDogGameOver, (020, 050))
    screen    if pygame.blitsprite.gropucollide(BoneDog, (550Bones, 100)True, True):
    screen.blit(Play, (600, 350))      Game = False
    screen.blit(Dog0, (5, 240))      GameOver = True
        while Game == True:
            pygame.displayevent.updatepump()
    mouse =       if pygame.mousekey.get_posget_pressed()[K_UP]:
                for i in range(10): # Up
                    Dog1_pos_y = Dog1_pos_y -1
                    screen.blit(background, (0, 0))
                    screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
                    screen.blit(SpikeUp0SpikeDown0, (0, 0436))
                    screen.blit(SpikeDown0SpikeUp0, (0, 4360))
                    pygame.display.update()
    while Game == True             pygame.time.delay(1)
            else: # Down
                Dog1_pos_y = Dog1_pos_y +1
                screen.blit(background, (0, 0))
                screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
                screen.blit(SpikeDown0, (0, 436))
                screen.blit(SpikeUp0, (0, 0))
        pygame.display.update()
        pygame.timedisplay.delayupdate(1)
    while True:
        if Crash:
  pygame.time.delay(1)
          Game = false
            GameOver.GameOver
    for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
                pygame.display.update()
                
    
   
if __name__ == "__main__":
    main()

I'm making my first game of Pygame. I'm going to create groups for the collisions but when I add an object to the group, I get an error in sprite.py in Pygame's files:

What I'm doing wrong?

There is my code (This file is imported from main.py, that's why things are missing in the code):

import pygame
from pygame.locals import *
import sys
import os
import time
from pygame.locals import *
width = 950
height = 500
Spikes = 1
Game = False

def play():
    Game = True
    pygame.init()
    screen = pygame.display.set_mode((width, height))
    pygame.display.set_caption('Flappy Dog')
    background = pygame.image.load(os.path.join("Images", "Background_00.png")).convert()
    FlappyDog = pygame.image.load(os.path.join("Images", "Flappy.png")).convert_alpha()
    Play = pygame.image.load(os.path.join("Images", "Play.png")).convert_alpha()
    Dog0 = pygame.image.load(os.path.join("Images", "Dog0.png")).convert_alpha()
    Dog1 = pygame.image.load(os.path.join("Images", "Dog1.png")).convert_alpha()
    SpikeUp0 = pygame.image.load(os.path.join("Images", "SpikeUp0.png")).convert_alpha()
    SpikeUp1 = pygame.image.load(os.path.join("Images", "SpikeUp1.png")).convert_alpha()
    SpikeDown0 = pygame.image.load(os.path.join("Images", "SpikeDown0.png")).convert_alpha()
    SpikeDown1 = pygame.image.load(os.path.join("Images", "SpikeDown1.png")).convert_alpha()
    GameOver = pygame.image.load(os.path.join("Images", "Game-Over.png")).convert_alpha()
    Replay = pygame.image.load(os.path.join("Images", "Replay.png")).convert_alpha()
    Bone = pygame.image.load(os.path.join("Images", "Bone.png")).convert_alpha()
    
    bonesSpikes = pygame.sprite.Group()
    bonesSpikes.add (SpikeDown0)
    bonesSpikes.add (SpikeUp0)
    bonesSpikes.add (Bone)
    Dog = pygame.sprite.Group()
    Dog.add(Dog1)
    Crash = pygame.sprite.spritecollide(Dog, bonesSpikes, True)
    
    Dog1_pos_x = 100
    Dog1_pos_y = 100
    screen.blit(background, (0, 0))
    screen.blit(FlappyDog, (0, 0))
    screen.blit(Bone, (550, 100))
    screen.blit(Play, (600, 350))
    screen.blit(Dog0, (5, 240))
    pygame.display.update()
    mouse = pygame.mouse.get_pos()


    screen.blit(background, (0, 0))
    screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
    screen.blit(SpikeUp0, (0, 0))
    screen.blit(SpikeDown0, (0, 436))
    pygame.display.update()
    while Game == True:
        Dog1_pos_y = Dog1_pos_y +1
        screen.blit(background, (0, 0))
        screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
        screen.blit(SpikeDown0, (0, 436))
        screen.blit(SpikeUp0, (0, 0))
        pygame.display.update()
        pygame.time.delay(1)
    while True:
        if Crash:
            Game = false
            GameOver.GameOver
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
            pygame.display.update()

I'm making my first game of Pygame. I'm going to create groups for making collisions but when I add an object to the group, I get an error in sprite.py (Pygame's Files)

Why I get this error?
There is a simplest way to make collisions?

There is my code:

import pygame
from pygame.locals import *
import sys
import os
import time
width = 950
height = 500
Game = False
GameOver = False
keyboard = pygame.key.get_pressed()[K_UP]
def main():
    pygame.init()
    screen = pygame.display.set_mode((width, height))
    pygame.display.set_caption('Flappy Dog')
    background = pygame.image.load(os.path.join("Images", "Background_00.png")).convert()
    FlappyDog = pygame.image.load(os.path.join("Images", "Flappy.png")).convert_alpha()
    Play = pygame.image.load(os.path.join("Images", "Play.png")).convert_alpha()
    Dog0 = pygame.image.load(os.path.join("Images", "Dog0.png")).convert_alpha()
    Dog1 = pygame.image.load(os.path.join("Images", "Dog1.png")).convert_alpha()
    SpikeUp0 = pygame.image.load(os.path.join("Images", "SpikeUp0.png")).convert_alpha()
    SpikeUp1 = pygame.image.load(os.path.join("Images", "SpikeUp1.png")).convert_alpha()
    SpikeDown0 = pygame.image.load(os.path.join("Images", "SpikeDown0.png")).convert_alpha()
    SpikeDown1 = pygame.image.load(os.path.join("Images", "SpikeDown1.png")).convert_alpha()
    GameOver = pygame.image.load(os.path.join("Images", "Game-Over.png")).convert_alpha()
    Replay = pygame.image.load(os.path.join("Images", "Replay.png")).convert_alpha()
    Bone = pygame.image.load(os.path.join("Images", "Bone.png")).convert_alpha()
    
    Game = True
    Dog1_pos_x = 100
    Dog1_pos_y = 100
    screen.blit(background, (0, 0))
    screen.blit(FlappyDog, (0, 0))
    screen.blit(Bone, (550, 100))
    screen.blit(Play, (600, 350))
    screen.blit(Dog0, (5, 240))
    bones = pygame.sprite.Group()
    bones.add(Bone) # <-- Error here
    Dog = pygame.sprite.Group()
    Dog.add(Dog1)
    pygame.display.update()
    
     
    while True:
        if GameOver == true:
            screen.blit(background, (0, 0))
            screen.blit(GameOver, (20, 50))
        if pygame.sprite.gropucollide(Dog, Bones, True, True):
            Game = False
            GameOver = True
        while Game == True:
            pygame.event.pump()
            if pygame.key.get_pressed()[K_UP]:
                for i in range(10): # Up
                    Dog1_pos_y = Dog1_pos_y -1
                    screen.blit(background, (0, 0))
                    screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
                    screen.blit(SpikeDown0, (0, 436))
                    screen.blit(SpikeUp0, (0, 0))
                    pygame.display.update()
                    pygame.time.delay(1)
            else: # Down
                Dog1_pos_y = Dog1_pos_y +1
                screen.blit(background, (0, 0))
                screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
                screen.blit(SpikeDown0, (0, 436))
                screen.blit(SpikeUp0, (0, 0))
                pygame.display.update()
                pygame.time.delay(1)
            
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
                pygame.display.update()
                
    
   
if __name__ == "__main__":
    main()
Post Undeleted by GospelBG
Post Deleted by GospelBG
fixed grammar
Source Link
GospelBG
  • 73
  • 2
  • 14

I'm making my first game of Pygame. II'm going to create groups for the collisions but when I add an object to the group, I get an error in sprite.py in Pygame's files:

I'm making my first game of Pygame. I going to create groups for the collisions but when I add an object to the group I get an error in sprite.py in Pygame's files:

I'm making my first game of Pygame. I'm going to create groups for the collisions but when I add an object to the group, I get an error in sprite.py in Pygame's files:

Source Link
GospelBG
  • 73
  • 2
  • 14

Pygame Error AttributeError: 'pygame.Surface' object has no attribute 'add_internal'

I'm making my first game of Pygame. I going to create groups for the collisions but when I add an object to the group I get an error in sprite.py in Pygame's files:

AttributeError: 'pygame.Surface' object has no attribute 'add_internal'

What I'm doing wrong?

There is my code (This file is imported from main.py, that's why things are missing in the code):

import pygame
from pygame.locals import *
import sys
import os
import time
from pygame.locals import *
width = 950
height = 500
Spikes = 1
Game = False

def play():
    Game = True
    pygame.init()
    screen = pygame.display.set_mode((width, height))
    pygame.display.set_caption('Flappy Dog')
    background = pygame.image.load(os.path.join("Images", "Background_00.png")).convert()
    FlappyDog = pygame.image.load(os.path.join("Images", "Flappy.png")).convert_alpha()
    Play = pygame.image.load(os.path.join("Images", "Play.png")).convert_alpha()
    Dog0 = pygame.image.load(os.path.join("Images", "Dog0.png")).convert_alpha()
    Dog1 = pygame.image.load(os.path.join("Images", "Dog1.png")).convert_alpha()
    SpikeUp0 = pygame.image.load(os.path.join("Images", "SpikeUp0.png")).convert_alpha()
    SpikeUp1 = pygame.image.load(os.path.join("Images", "SpikeUp1.png")).convert_alpha()
    SpikeDown0 = pygame.image.load(os.path.join("Images", "SpikeDown0.png")).convert_alpha()
    SpikeDown1 = pygame.image.load(os.path.join("Images", "SpikeDown1.png")).convert_alpha()
    GameOver = pygame.image.load(os.path.join("Images", "Game-Over.png")).convert_alpha()
    Replay = pygame.image.load(os.path.join("Images", "Replay.png")).convert_alpha()
    Bone = pygame.image.load(os.path.join("Images", "Bone.png")).convert_alpha()
    
    bonesSpikes = pygame.sprite.Group()
    bonesSpikes.add (SpikeDown0)
    bonesSpikes.add (SpikeUp0)
    bonesSpikes.add (Bone)
    Dog = pygame.sprite.Group()
    Dog.add(Dog1)
    Crash = pygame.sprite.spritecollide(Dog, bonesSpikes, True)
    
    Dog1_pos_x = 100
    Dog1_pos_y = 100
    screen.blit(background, (0, 0))
    screen.blit(FlappyDog, (0, 0))
    screen.blit(Bone, (550, 100))
    screen.blit(Play, (600, 350))
    screen.blit(Dog0, (5, 240))
    pygame.display.update()
    mouse = pygame.mouse.get_pos()


    screen.blit(background, (0, 0))
    screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
    screen.blit(SpikeUp0, (0, 0))
    screen.blit(SpikeDown0, (0, 436))
    pygame.display.update()
    while Game == True:
        Dog1_pos_y = Dog1_pos_y +1
        screen.blit(background, (0, 0))
        screen.blit(Dog1, (Dog1_pos_x, Dog1_pos_y))
        screen.blit(SpikeDown0, (0, 436))
        screen.blit(SpikeUp0, (0, 0))
        pygame.display.update()
        pygame.time.delay(1)
    while True:
        if Crash:
            Game = false
            GameOver.GameOver
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
            pygame.display.update()