Why is the above grammar not showing up?


#1

var mass = [];
var positionX = [];
var positionY = [];
var velocityX = [];
var velocityY = [];

/////////////////////////////////////////////////////////////////////////////////////////////////////

function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
fill(255, 3, 0, 170);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////

function draw() {
background(32);

for (var particleA = 0; particleA < mass.length; particleA++) {
var accelerationX = 0, accelerationY = 0;

for (var particleB = 0; particleB < mass.length; particleB++) {
  if (particleA != particleB) {
    var distanceX = positionX[particleB] - positionX[particleA];
    var distanceY = positionY[particleB] - positionY[particleA];

    var distance = sqrt(distanceX * distanceX + distanceY * distanceY);
    if (distance < 1) distance = 1;

    var force = (distance - 300) * mass[particleB] / distance;
    accelerationX += force * distanceX;
    accelerationY += force * distanceY;
  }
}

velocityX[particleA] = velocityX[particleA] * 0.99 + accelerationX * mass[particleA];
velocityY[particleA] = velocityY[particleA] * 0.99 + accelerationY * mass[particleA];

}

for (var particle = 0; particle < mass.length; particle++) {
positionX[particle] += velocityX[particle];
positionY[particle] += velocityY[particle];

ellipse(positionX[particle], positionY[particle], mass[particle] * 1000, mass[particle] * 1000);

}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////

function addNewParticle() {
mass.push(random(0.003, 0.03));
positionX.push(mouseX);
positionY.push(mouseY);
velocityX.push(0);
velocityY.push(0);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////

function mouseClicked() {
addNewParticle();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////

function mouseDragged() {
addNewParticle();
}


#2

pls to make the code readable/usable
paste it again using the

</>

code formatter

or much better,
open a account and run it at
https://editor.p5js.org/

also some more words about the problem,
what is ?grammar?


#3

Thanks for the big reply


#4

@alk5603 Did the reply make sense? Let us know if you need anymore assistance. Best of Luck!


#5

sorry, but i am serious about that,
in month you open 12 threads, some with posting unreadable code like this,
i not want to check on how many times already you have been asked to format your code.

so pleaseā€¦
repair above code pasting, once you learned how to do,
you might see that it is so easy ( and fast ? under a second ? )

and again?
pls. tell us in other words where you see a problem ? code/line

  • what happen
  • what error msg.
  • possibly a screenshot?