Python Forum
how can i solve this videogame error?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how can i solve this videogame error?
#3
group is a container that holds objects. There is no reason to call its object, but call its objects methods .
Quote:
def newdrop():
    Drop1 = pygame.sprite.Group()
    d = Drop1()
    all_sprites.add(d)
    drop.add(d)

You would do something like this

# This is a list of 'sprites.' Each block in the program is
# added to this list.
# The list is managed by a class called 'Group.'
block_list = pygame.sprite.Group()
 
# This is a list of every sprite.
# All blocks and the player block as well.
all_sprites_list = pygame.sprite.Group()

...

for i in range(50):
    # This represents a block
    block = Block(BLACK, 20, 15)
 
    # Set a random location for the block
    block.rect.x = random.randrange(screen_width)
    block.rect.y = random.randrange(screen_height)
 
    # Add the block to the list of objects
    block_list.add(block)
    all_sprites_list.add(block)

...

player = Block(RED, 20, 15)
all_sprites_list.add(player)
full example here
http://programarcadegames.com/index.php?...to_sprites
Recommended Tutorials:
Reply


Messages In This Thread
how can i solve this videogame error? - by abscorpy - Jan-22-2018, 06:52 PM
RE: how can i solve this videogame error? - by metulburr - Jan-22-2018, 08:32 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020