Dec-09-2019, 08:18 PM
You have a player class already (with position, rotation, hit boxes, etc), add the info there. I'm not sure the LanderState (or any state) should be creating the player, though.
So instead of...
So instead of...
class Landerstate(States): def __init__(self, screenrect, player.location, player.money): ## <--------- and add info here? States.__init__(self) self.next = 'starmap' self.players = pygame.sprite.Group() self.all_sprites = pygame.sprite.Group() self.planet_surface = Planet_surface() self.all_sprites.add(self.planet_surface) self.minerals = pygame.sprite.Group() self.player = Player(300, 400) self.all_sprites.add(self.player) self.players.add(self.player) self.place_minerals()...try this...
class Landerstate(States): def __init__(self, screenrect, player): ## <--------- player already exists States.__init__(self) self.next = 'starmap' self.players = pygame.sprite.Group() self.all_sprites = pygame.sprite.Group() self.planet_surface = Planet_surface() self.all_sprites.add(self.planet_surface) self.minerals = pygame.sprite.Group() self.player = player ### self.player = Player(300, 400) # no longer needed, player already exists self.all_sprites.add(self.player) self.players.add(self.player) self.place_minerals()