Uncle_batty
Uncle_batty

Reputation: 71

Pygame player position

So I'm making a platformer in pygame and I was quite far along in the code when I changed how the levels where gonna be set up so I now needed to have the player start at the top of the screen instead of the bottom so it was simple I just needed to change the attributes witch I call into my player class so tat the position can change as that's how it was set in the first place but the player just kept starting in the same place

player = player(100,screen_height+100)

def tryagain(self,x,y):
    player1 = pygame.image.load('guy.png')
    self.image = pygame.transform.scale(player1, (40,75))
    self.rect = self.image.get_rect()
    self.rect.center = (x,y)

2 class player(): def __init__(self, x, y): self.tryagain(x,y)

screen.blit(self.image, self.rect)

i even coded all the code from the start but now the Collisions with platforms refuse to work even thoi never chaged that code

Upvotes: 1

Views: 1035

Answers (1)

Rabbid76
Rabbid76

Reputation: 210889

The top left of the pygame coordinate system is (0, 0):

player = player(100,screen_height+100)

player = player(100, 100)

Upvotes: 1

Related Questions