PyGame Endless Vertical Platformer Beginner Tutorial in Python - PART 3 | Keyboard Input

preview_player
Показать описание
In this Python tutorial I code an endless vertical platformer using the PyGame module. I'm going to explain how to add keyboard inputs to control the player

Credits for assets used:

Check out my other PyGame tutorials:
Рекомендации по теме
Комментарии
Автор

thanks for this. I've learnt a lot of things in python, but this has been my first venture into pygame, and your videos are the only ones that make it make sense

eagle
Автор

Great video as always Russ!
i've managed to add some code to make the movement a little bit more fluid, if anyone wants it:
if (key[pygame.K_a]):
self.direction = -1
self.flip = False
dx -= self.movement_speed + self.momentum
if (self.momentum < 5):
self.momentum += 0.5

elif (key[pygame.K_d]):
self.direction = 1
self.flip = True
dx += self.movement_speed + self.momentum
if (self.momentum < 5):
self.momentum += 0.5
else:
#if no keys are pressed, gradually lower the momentum
if (self.momentum > 0):
dx += (self.movement_speed * self.direction) + (self.momentum * self.direction)
self.momentum -= 0.5
self.momentum and self.direction start at 0, you can play with the variables depending on your needs.

MrSpaceWhale
Автор

Hey dude.

I gotta ask...do you have any recommendations on the resources you use?

HoRRoRlets
Автор

If i turn to the left, my hitbox changes, how to fix this?

Nehemus
join shbcf.ru