From dd325d2d35eda485bb4dc05797a648774b2498f6 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 3 Oct 2021 18:41:52 +0200 Subject: Create project --- projects/projectile/index.html | 1 + projects/projectile/index.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 projects/projectile/index.html create mode 100644 projects/projectile/index.js (limited to 'projects/projectile') diff --git a/projects/projectile/index.html b/projects/projectile/index.html new file mode 100644 index 0000000..63d2a68 --- /dev/null +++ b/projects/projectile/index.html @@ -0,0 +1 @@ +BLABLABLABL diff --git a/projects/projectile/index.js b/projects/projectile/index.js new file mode 100644 index 0000000..4226da5 --- /dev/null +++ b/projects/projectile/index.js @@ -0,0 +1,40 @@ + + +let projectile= function (node){ + + node.setup = function() { + node.createCanvas(width, height); + }; + + + let t=0; + let v0=50 + let x0=1 + let y0=50 + let g=9.81 + let width=800 + let height=200 + let dots=[] + function x(t) { + return x0+v0*t + } + + function y(t) { + return height - (-1/2 * g * t**2 + v0 * t + y0) + } + + node.draw = function() { + node.background(50); + dots.forEach((elt)=>{node.ellipse(elt[0],elt[1],4,4);}) + node.ellipse(x(t),y(t),20,20); + dots.push([x(t),y(t)]) + if(t>10){ + node.noLoop() + } + t+=0.07 + }; + + node.a=function(){ + node.remove() + } +}; -- cgit v1.2.3