Using and making sprite groups

93 views Asked by At

I'm creating a sprite class Character, this class has the methods makeCharacter, add, remove

troll = Character()

#this makes 10 characters troll to appear at any position x,y given by the user.

makeCharacter(troll,10,[position])
remove(troll,3)
add(troll,10)

I want the characters image to be determined by a method, setImage

If its possible, all trolls in the sprite group to have their image changed, and an option for individual sprites in a group to have their image changed.

so if troll.setImage("troll.png") is called, then the image of the troll should automatically change to a trolls, and if another object monster was called and the same was applied, then a picture of a monster to appear for that sprite.

So far for the make character i have the following for makeCharacter

def makeCharacters(self,Character, numberOfcharacters,[positionx, positiony]):
    for i in range(numberOfcharacters):
        self.trolls.add(troll, [positionx, positiony])
        self.window.blit(character.image,(positionx,positiony))

I don't want the character _init_ constructor for the character class to initialize the position

This method does not work.

Any suggestions?

0

There are 0 answers