Complete beginner here (on this site as well so please be kind) and trying to learn some coding on my free time. Been following this brilliant tutorial https://www.youtube.com/watch?v=AY9MnQ4x3zk but I'd love to make my player move left and right as well and here is only jumping added. I have been doing a great deal of googling, trial and error, but the poor bastard aint moving sideways. I would be thrilled if someone could help!
player = pygame.image.load('player.png').convert_alpha()
player_rect = player.get_rect(midbottom = (80,422))
player_gravity = 0
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
if game_active:
# JUMP command
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and player_rect.bottom >= 422:
player_gravity = -20
Tried adding x and y coordinates but did not work and neither did key get pressed function :(