Share your repls and programming experiences

← Back to all posts
Pygame Physics Engine
EthanCulp

This is a very simple physics engine that can save you so much time when making a game that uses physics. To see how much time it saves, look at this project, made with no engine, just the pygame module:
https://repl.it/@EthanCulp/Boxer.

It has over 300 lines of code! And all it does is make a square that just jumps around.

With this physics engine, I can make almost the exact same program with only 130 lines! (It can be shortened down without comments).

This project would not have been possible without mwilki7's (Look below for his profile) help. He was the one dealing with all of the physics stuff, and I was the one doing Pygame, as he doesn't have much experience with it, so thank you.

If you have any questions, feel free to ask.

Contributers:
@mwilki7

Mentions:
@ChezCoder Thanks for helping point out a flaw in the engine (The flaw was not being able to change the velocity)

Edit: The project has been uploaded to PYPI. If you want to look at it, go to this URL to view the documentation. To install, type this in your command prompt:
python -m pip install PygamePhysics

Voters
ichbindede
tankerguy1917
Highwayman
Roar123
jackou
ARJPEG
ChezCoder
mkhoi
xolyon
mwilki7
Comments
hotnewtop
ChezCoder

Im impressed! Just that the speed kills me XD

EthanCulp

Thanks! You also just introduced a problem to me on the engine

The problem is with collisions, if the vel is not divisible by 5, collisions don't work. For now I just made the program run faster, but to make it run at normal speed, it is going to be long fix, but thanks for making aware of that
@ChezCoder

ChezCoder

@EthanCulp lol now the hitboxes are broken XD

EthanCulp

Oh, darn XD @ChezCoder
Edit- Fixed now
Edit 2- I fixed the velocity glitch

ChezCoder

@EthanCulp very nice! Also thx for the mention :D

EthanCulp
Highwayman

.

👌

ChezCoder

@Highwayman guess what? repl FINALLY updated node!!!!! YESSSSS

Highwayman

@ChezCoder

EGADS!

Seems we’re getting somewhere. XD

CPU?

ChezCoder

@Highwayman sorry for not replying, been busy these days :(

jackou

angry fps noises

But seriously, good work bro. Keep it up! :D

EthanCulp
ChezCoder
EthanCulp

@ChezCoder Well guess what, I did it ALL BY MYSELF, and I didn't need your help. Probably would have saved me a few days tho if this was up earlier lol

xolyon

Very Nice , good job

EthanCulp

Thanks! 😃 @xolyon

mwilki7

awesome you got the collisions to work well

EthanCulp

OMG DON'T EVEN GET ME STARTED WITH THE COLLISIONS