Physics + Collision | Coding Terraria in Python | Pygame Tutorial Ep. 5

preview_player
Показать описание
Thanks for watching!
Code available at 20 likes!

Join my Discord:

Consider supporting me on Patreon :)
Рекомендации по теме
Комментарии
Автор

I suggest you give the player character movement acceleration to make it more smooth when changing directions

IwasOnceCooler
Автор

That’s 20 likes right there, great series so far, thanks!

rethanon
Автор

Another way to fix the problem you had, where the player could still jump once, after walking off the edge:
Inside player.move() I put this:

If self.velocity.y > GRAVITY * self.mass:
self.grounded = False

This means: "if the player is at least one frame into the act of falling, then the player isnt grounded"
In other words, if you are falling, then obviously there is nothing directly under you to be grounded on.
I found this works better than the collisions+=1 check you did, because jumping wasn't always registering when I pressed space, and other times it did. So I found a more reliable solution.

Hope this helps someone out there

live_destin-