Gravity

This program generates rectangular prisms when the mouse is pressed. The prisms gravitate towards each other. Movement is possible through WASD and moving the mouse. While making this, I ran into problems with rotating the screen, which I solved by switching the x and y mouse rotations. I also had problems with gravity. When I attempted to implement gravity, the object's velocity would return NaN when an object tried to apply gravity to itself (divide by zero error). I fixed this by adding a check to make sure objects did not apply gravity to themselves.
e.g., mouse, keyboard
e.g., visualization, fractal, mouse
Learn more about Creative Commons
Join Plus+ to change privacy settings
  • sketch103140
This will be the default layout for your sketches
Easy on the eyes
It will show up when there is an error or print() in code
Disabled: Only available on p5js sketches.
Closes parenthesis-like characters automatically as you type

Controls
Play
Ctrl+Enter
Code
Ctrl+Shift+Enter
Save
Ctrl+S
Interface
Fullscreen
Ctrl+Alt+F
Switch Layout
Ctrl+Alt+L
Settings
Ctrl+Alt+.
Editor
Tidy Code
Ctrl+B
Multiple Cursors
Ctrl+Click
Duplicate Line/Selection
Ctrl+Shift+D
Move Line
Alt+↑/↓
Select Multiple
Ctrl+D
Find in Code
Ctrl+F
Find Next
Ctrl+G
Find Previous
Ctrl+Shift+G

See More Shortcuts

Join Plus+ for private sketches, version history, 1GB space, custom embeds, and more!