(I don't mean that subtracting gives a different mathematical result than addition-that's obvious) I'm trying to make a particle simulator game, and I ran into a weird phenomenon. (I'm using javascript with javap5.js). In the draw function, I have a function that test if the space below a particle is empty, and if it is, it moves down by one pixel(or adding one to the result-that's where the addition is) The only issue is, instead of a gradual change when going down, it INSTANTLY goes to the bottom of the screen. When I use subtraction instead(so gravity is up) it behaves as expected and goes up gradually. Here's the function I'm talking about(game is the array of particles)-
function updateParticles() {
for(var i = 0; i<250; i++) {
for(var i2 = 0; i2<250; i2++) {
if(game[i][i2] == 1) {
if(game[i][i2+1] == 0) {
game[i][i2]=0;
game[i][i2+1]=1;
}
}
}
}
}
and here is the whole thing(jsfiddle)- https://jsfiddle.net/gwood5901/trm6xLv8/