Share your repls and programming experiences

← Back to all posts
Physics Engine (Kinda)
BrokenKeyboard

Physics engine, still in progress.

Usage:

So, all you have to do is the following.
Click and drag and then release to launch a box.
The longer you hold down the mouse, the more mass it has.
The phyiscs are all homebrew and pretty simple.
Please vote if you like it, and bananas are welcome payment.

Any questions? Ask!

Voters
seanlnge
YuAndy
b30wulf
ethanshaozz1928
XxMustardCatxX
Nayoar
TsunamiOrSumth
adsarebbbad
legobuddy63
Gr8est
Comments
hotnewtop
sleepyperson123

@BrokenKeyboard how do i add collisions

heres a bananana 🍌

CONNERSTANEK

If you do make collisions then you will have to make the size have a max because if you would make the shape the size of the work area then make another shape it will just glitch badly. Sorry if i explained it bad if you dont get what i'm saying ask me.

BrokenKeyboard

@CONNERSTANEK I dont plan on working on this more, but if/when I do add collisions, then ill be sure to ping you.

cowboyyall10

dude in style.css just add a bit of color with

main{
background-color: color
}

YuAndy

Something tells me that you could make a really fun random generator with this.

iocoder

i think i got too much mass

iocoder

@ridark press move to a corner, count down 30 second and then stop pressing and you get BIG BOY (it fills the whole gray box

NoNameByProgram

gravity is gone

adsarebbbad

awesome :O

mwebbtcslj

how do you play?
:(

techde

@mwebbtcslj Its not a game.

XxMustardCatxX

@mwebbtcslj click anywhere in the gray box lmao

ch1ck3n


i like it, this is fun.

fuzzyastrocat

Aww, no collisions? That's where all the madness fun happens!

realTronsi

@fuzzyastrocat for circle's it's actually quite easy

correction: collisions with polygons, that's where all the fun begins :D

fuzzyastrocat

@realTronsi Well yes, circle collision detection is easy. But even with circles collision resolution is difficult.

So no, I keep my original statement.

realTronsi

@fuzzyastrocat actually since it's uniform on all sides you literally only have to account for 1 point at the bare minimum and run some physics depending on their velocities to determine how much they're offset. The actual direction isn't too difficult either (obviously comparing to irregular polygons) because you can use basic trigonometry to determine which direction the ball bounces, since there's only two variations of colliding up and colliding past, there aren't too many cases to consider, and you could hard code it if you want.

fuzzyastrocat

@realTronsi

run some physics depending on their velocities to determine how much they're offset

This is the difficult part, because having multiple circles collide at once can get really glitchy.

Arbiter1227

@fuzzyastrocat It could be worse.

There could be no border collision.

fuzzyastrocat

@Arbiter1227 Heh, true.

realTronsi

@fuzzyastrocat well true, if implemented incorrect,ly, but we can prioritize the ball with the greater velocity, such that multiple colliding balls will just result in a domino effect where all balls are pushed away.

BrokenKeyboard

@realTronsi I do plan on fleshing out the physics once I have time, and the rects will become circles and then it will have collision. Maybe I will add angular velocity so that it could spin and stuff

XxMustardCatxX

@fuzzyastrocat Its actually probably really hard to:
1) Code that
2) Actually get the balls to hit each other cause they're so damn small

fuzzyastrocat

@XxMustardCatxX Of course it's hard, but it's not like anyone forced them to make a physics engine. It's not really a physics engine without collisions.

(Also the small thing isn't really an issue.)

BrokenKeyboard

@fuzzyastrocat Also, im putting the engine on hold as im working on a boid simulation (flocking behaviour)

BrokenKeyboard

@XxMustardCatxX and if the problem is them being small ill just increase the size/time ratio (basically holding down will increase the size faster)

BD103

O/o

This is amazing!

Though maybe add a cap to the box size, I accidentally made one bigger than the canvas. :D

JDOG787

@BD103 same lol

ComputingSquid

yeah @BD103

RayhanADev

sad mobile noises seems legit! One bug though, I make a tiny (barely clicked) dot and it stays in place. Otherwise cool p5 project, always great to see someone else use that amazing library xD.

k9chelsea2

cool teach me your ways

Coder100

the things are so bouncy have an option to make bouncing less (and also recursive calculations for collisions between the things!)

BrokenKeyboard

@Coder100 The reason for the bounciness is bcs the ground absorbs only 10% of the acceleration, but im going to change it a bit to make it more realistic.

Coder100

pOg