Share your repls and programming experiences

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

After 2 hours of fixing the code 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!!!!!!!!!!!!!

KTHXBAI :)

Voters
ruiwenge2
Alexify
Kai_Justice
P0GCHAMPB0i
piphi
MarcusWeinberger
AlexSteele1
tvmp
Rufus310
KadenMcDonald1
Comments
hotnewtop
ch1ck3n

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

PixiGem

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

FlaminHotValdez

@ch1ck3n needs pog award

ch1ck3n

@FlaminHotValdez

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

noice make sure to update the pog awards web @ch1ck3n

PixiGem

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

ch1ck3n
PixiGem

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

RayhanADev

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

JWZ6

@RayhanADev my 2 posts were the first XD

xMisbahx

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

IGamer123

haha yes

FlaminHotValdez

@IGamer123 that is copyrighted by HaHaYes

IGamer123
MemeManHimself

Gravity Google vibes

imnew12

its is cool but maybe increase the canvas size?

Bookie0

:(

PixiGem

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

Bookie0

oh ok @PixiGem

tussiez

Nice!

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

RayhanADev

^

BenjaminHolm1

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

PixiGem

@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

@HyperDev100 oh okay, still impressive tho

HumanMcHuman

make it ttris

FlaminHotValdez

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

JWZ6

@FlaminHotValdez ikr so pog

bgrubert


The project: 10,000+ lines of code

Baconman321

@bgrubert Uhh, no.

He wrote only about 20 lines JS.

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

bgrubert

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

Arabica

@bgrubert I acutally have a very basic physics engine.
(No physics library of any kind!)
https://replit.com/@Arabica/2DPhysicsEngine

bgrubert

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

dObbOb11

10428 LiNEs....

Baconman321

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

It's still cool, tho.

billiv3x

nice

RahulChoubey1

I can ss now so umm epic gamer castle:

RahulChoubey1

roblox physics be like

RahulChoubey1

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

SudhanshuMishra

@RahulChoubey1 hey rahul , u got anything from ahkid ?

mollthecoder

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

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

PixiGem

@VulcanWM Sure! btw sorry for the late reply

VulcanWM

ty! it's okay @HyperDev100

PixiGem

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

VulcanWM

already did :) @HyperDev100

VulcanWM

also i'm using your code from this repl anyways: https://physics-go-brrrrr.hyperdev100.repl.co/matter.js
@HyperDev100

EdwardBentler

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

AndrewAung11

@EdwardBentler
Our live without stack overflow:

PixiGem

@AndrewAung11 lol true