Share your repls and programming experiences

← Back to all posts
Realistic 2D Physics in JavaScript!
PixiGem (105)

Recently on GitHub, I found something called "matter.js physics engine", using that, I made this.

After 2 hours of exploring the code of matter.js and StackOverflow, I made this!

Hope you enjoy this little project of mine :)

You can move the blocks using your mouse

A few things you can do with this -

  • Build something
  • Throw everything!
  • Enjoy the Physics!!!!!!!!!!!!!


ch1ck3n (2052)

I put pictures of things i hate on the canvas and throw blocks at it

PixiGem (105)

@ch1ck3n Ig I shud make somethin like that lol. prob an image upload button and these blocks.

ch1ck3n (2052)


i hereby award this pog creation of one of the upper pog coders ... THE POG AWARD!!

approved by ch1ck3n, founder of the pog awards comitee

JWZ6 (648)

noice make sure to update the pog awards web @ch1ck3n

PixiGem (105)

@ch1ck3n noice* let's make website for pog awards, and I'm not joking!

PixiGem (105)

@ch1ck3n what else do you think to add to the website?
maybe a poggy award leaderboard?

RayhanADev (2514)

@HyperDev100 my game would be first since it's the og winner

JWZ6 (648)

@RayhanADev my 2 posts were the first XD

xMisbahx (4)

it brings me pure joy to destroy things. especially when in sandbox games(no consequences). I would suggest that you make it so that the blocks stay inside the screen so that more destruction happens

imnew12 (2)

its is cool but maybe increase the canvas size?

PixiGem (105)

@Bookie0 Thats coz I changed my name :( you can run it in replit and not a new tab

tussiez (1647)


However your project is just a demo for a library, doesn't need soo many upvotes, lol

BenjaminHolm1 (0)

Did you write 10k lines of code or did you copy some/a lot of it?

PixiGem (105)

@BenjaminHolm1 it is a library on Github, I also added a few lines of code to the library, "matter.js". (a few lines of code means 134 lines of code lol)

BenjaminHolm1 (0)

@HyperDev100 oh okay, still impressive tho

FlaminHotValdez (686)

Today I learned that if you take a block and yeet it downwards onto two stacks of blocks, everything will explode.

bgrubert (124)

The project: 10,000+ lines of code

Baconman321 (1097)

@bgrubert Uhh, no.

He wrote only about 20 lines JS.

He used a pre-wrote library, made by someone else.

bgrubert (124)

@Baconman321 Ik they copied the library, it's just ironic that the script.js file is 10k lines.

Arabica (10)

@bgrubert I acutally have a very basic physics engine.
(No physics library of any kind!)

bgrubert (124)

@Arabica Wow! I'm usually too lazy, and just copy formulas, or use libraries.

Baconman321 (1097)

@dObbOb11 Yeah, that someone else made. He only wrote like 20 lines.

It's still cool, tho.

RahulChoubey1 (173)

I can ss now so umm epic gamer castle:

RahulChoubey1 (173)

roblox physics be like

RahulChoubey1 (173)

half the time the blocks are jello and half the time they're solid XD

SudhanshuMishra (250)

@RahulChoubey1 hey rahul , u got anything from ahkid ?

mollthecoder (37)

Maybe make things apply less force. I'd say my mouse cursor is pretty strong to lightly hit a cube with another one and see that cube fly off the screen.

VulcanWM (2755)

Hey, this is amazing! Can I use it for my new project?

PixiGem (105)

@VulcanWM Sure! btw sorry for the late reply

PixiGem (105)

@VulcanWM but yeah, give credits to the author of the library and me

EdwardBentler (35)

Amazing! (Also, lol, 2 hours of stack overflow, what would our lives be without it?)