xxxxxxxxxx
/*// posizione
let x, y;
// velocità
let vx, vy;
// raggio
let r = 20;
*/
// tempo
let t, dt;
function setup() {
createCanvas(windowWidth, windowHeight);
t = 0;
dt = 2;
// creazione dell'oggetto particella
p = new Particella(width / 2, height / 2, 1.2, 2, 30);
p2 = new Particella(0, 0, 3, 0.5, 15);
/*x = 0;
y = 0;
vx = 1.3;
vy = 1.5;
*/
}
function draw() {
background(135, 0, 0);
fill(255);
textSize(15);
text("tempo: " + t, 10, 25);
p.bordi();
p.muovi(dt);
p.disegna();
p2.bordi();
p2.muovi(dt);
p2.disegna();
t = t + dt;
/*
// aggiornare le variabili di stato
x = x + vx * dt;
y = y + vy * dt;
t = t + dt;
// disegnare l'oggetto
fill(120, 255, 255);
ellipse(x, y, 2 * r);
// universo sferico
if(x > width) x = 0;
if(x < 0) x = width;
if(y > height) y = 0;
if(y < 0) y = height;
muovi ();
disegna();
bordi();
*/
}
/*function muovi() {
x = x + vx * dt;
y = y + vy * dt;
t = t + dt;
}
function disegna() {
fill(120, 255, 255);
ellipse(x, y, 2 * r);
}
function bordi() {
if (x > width) x = 0;
if (x < 0) x = width;
if (y > height) y = 0;
if (y < 0) y = height;
}
*/