From 4754ec6adc5946fa674e68a1f6950786af479b58 Mon Sep 17 00:00:00 2001 From: Daniel Shiffman Date: Mon, 18 Mar 2013 15:42:25 -0400 Subject: [PATCH] comments reflection2 --- .../Topics/Motion/Reflection2/Ground.pde | 4 ---- .../Topics/Motion/Reflection2/Orb.pde | 5 ++++- .../Topics/Motion/Reflection2/Reflection2.pde | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/java/examples/Topics/Motion/Reflection2/Ground.pde b/java/examples/Topics/Motion/Reflection2/Ground.pde index 55d8497e2..acf7d3637 100644 --- a/java/examples/Topics/Motion/Reflection2/Ground.pde +++ b/java/examples/Topics/Motion/Reflection2/Ground.pde @@ -2,10 +2,6 @@ class Ground { float x1, y1, x2, y2; float x, y, len, rot; - // Default constructor - Ground(){ - } - // Constructor Ground(float x1, float y1, float x2, float y2) { this.x1 = x1; diff --git a/java/examples/Topics/Motion/Reflection2/Orb.pde b/java/examples/Topics/Motion/Reflection2/Orb.pde index a3e0d534a..570fc081a 100644 --- a/java/examples/Topics/Motion/Reflection2/Orb.pde +++ b/java/examples/Topics/Motion/Reflection2/Orb.pde @@ -1,7 +1,9 @@ class Orb { + // Orb has positio and velocity PVector position; PVector velocity; float r; + // A damping of 80% slows it down when it hits the ground float damping = 0.8; Orb(float x, float y, float r_) { @@ -22,7 +24,8 @@ class Orb { fill(200); ellipse(position.x, position.y, r*2, r*2); } - + + // Check boundaries of window void checkWallCollision() { if (position.x > width-r) { position.x = width-r; diff --git a/java/examples/Topics/Motion/Reflection2/Reflection2.pde b/java/examples/Topics/Motion/Reflection2/Reflection2.pde index e1967fe8d..d227e736b 100644 --- a/java/examples/Topics/Motion/Reflection2/Reflection2.pde +++ b/java/examples/Topics/Motion/Reflection2/Reflection2.pde @@ -9,16 +9,17 @@ Orb orb; PVector gravity = new PVector(0,0.05); +// The ground is an array of "Ground" objects int segments = 40; Ground[] ground = new Ground[segments]; -float[] peakHeights = new float[segments+1]; void setup(){ size(640, 360); + // An orb object that will fall and bounce around orb = new Orb(50, 50, 3); - // Calculate ground peak heights + float[] peakHeights = new float[segments+1]; for (int i=0; i