All Questions
Tagged with physics javascript
21
questions
6
votes
3
answers
312
views
Predict bouncing ball destination in JavaScript
In a Pong-style 2D game, a ball (a circle of radius BALLRADIUS) can bounce (with perfect elasticity) on the top or bottom of the screen. When it hits the left or right side of the screen, one of the ...
2
votes
1
answer
882
views
JS + CANVAS Projectile Motion [closed]
Basically you've got a canvas, and you can click it to launch a ball in a certain angle and speed, everything is working fine, except for the arrow tip of the vector thing. I can't get it to draw ...
2
votes
1
answer
1k
views
d3.js canvas performance
I've just rewritten this code (a simple gravitational restricted n-body simulation) to display using canvas, rather than SVG. The reason being that I'd like to be able to run it with many thousands of ...
4
votes
1
answer
88
views
Making basic physics object class
I'm creating a 2D game in JS, and I've made the generic class that all objects in the game will be (I've decided they are all circular for now).
An object has ...
6
votes
1
answer
484
views
Pong Game in JS
I am new to game development and took on the task to create a Pong replica due to my curiosity and interest in the field. I decided to write it in JavaScript because the game is not too labor ...
1
vote
1
answer
274
views
Closed particle system simulation in vanilla Javascript
I have ported my simulation from Java to vanilla Javascript. The most important aim was to keep the sum of all energies constant. I have this:
simulation.js
...
2
votes
1
answer
65
views
NodeJS module to calculate linear motion
I am on the process of changing jobs, so I would like to get an idea of what I do wrong in order to improve.
For this, I have created a small node module. It's very simple; it calculates linear ...
17
votes
3
answers
280
views
"Do I understand the gravity of the situation?"
What is this?
This is a two-dimensional physics simulator that models gravity and collisions between circular objects (though it doesn't model rotation).
How do you use it?
You can tweak the following ...
3
votes
1
answer
120
views
Quickly applying gravity force between bodies
I have a function for applying gravity forces between every possible pair of bodies on my game. It is the most used function, and can run more than 100k times per frame so every minor improvement on ...
7
votes
1
answer
2k
views
2D colliding disks in JavaScript (ideal billiard balls)
I am implementing a simulation of colliding disks (ideal 2D billiard balls) in JavaScript.
I follow an event-driven algorithm that avoids discretizing time; the algorithm goes as follows at each step:...
0
votes
1
answer
168
views
Calculating an object's stopping distance
I'm trying to smooth the movement of a cursor which has a set acceleration and max speed. I wrote this function to calculate the stopping distance of an object given its speed and acceleration, and it ...
3
votes
1
answer
728
views
Explosion animation plugin for a game
I have been writing a small particle plugin since I want to learn how physics works for games. Now I have tried to get this as clean as I possible could but It feels something is missing. Am I ...
12
votes
2
answers
1k
views
Gravitational Brute Force N-body Algorithm
I've just started dabbling with code, and as a learning exercise I've written a simple algorithm for solving gravitational n-body problems numerically in JavaScript.
I would be very grateful for ...
7
votes
1
answer
129
views
Animating a 2D particle "web"
I have written a small class to generate and animate one of those trendy particle webs. I plan to use this as the main background of my personal website, so naturally I'm concerned about the ...
7
votes
1
answer
336
views
Processing.js physics simulation
I've been fooling around in JavaScript again, and I've come up with this simple physics simulation. I think it has a pretty simple setup, here's "psuedocode" of sorts to explain it.
Constructor ...