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:
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()