Permalink
Browse files

location is now position everywhere

1 parent 5d19bd5 commit 4195df9d5774df4790b1d9d87cad934a82a59b50 @shiffman committed Jul 1, 2016
Showing with 1,089 additions and 1,099 deletions.
  1. +8 −8 chp01_vectors/NOC_1_10_motion101_acceleration/Mover.pde
  2. +1 −1 chp01_vectors/NOC_1_10_motion101_acceleration/NOC_1_10_motion101_acceleration.pde
  3. +8 −8 chp01_vectors/NOC_1_11_motion101_acceleration_array/Mover.pde
  4. +1 −1 chp01_vectors/NOC_1_11_motion101_acceleration_array/NOC_1_11_motion101_acceleration_array.pde
  5. +2 −2 chp01_vectors/NOC_1_1_bouncingball_novectors/NOC_1_1_bouncingball_novectors.pde
  6. +8 −8 chp01_vectors/NOC_1_2_bouncingball_vectors/NOC_1_2_bouncingball_vectors.pde
  7. +8 −8 chp01_vectors/NOC_1_2_bouncingball_vectors_object/Ball.pde
  8. +8 −11 chp01_vectors/NOC_1_3_vector_subtraction/NOC_1_3_vector_subtraction.pde
  9. +1 −1 chp01_vectors/NOC_1_6_vector_normalize/NOC_1_6_vector_normalize.pde
  10. +12 −12 chp01_vectors/NOC_1_7_motion101/Mover.pde
  11. +12 −12 chp01_vectors/NOC_1_8_motion101_acceleration/Mover.pde
  12. +12 −12 chp01_vectors/NOC_1_9_motion101_acceleration/Mover.pde
  13. +10 −10 chp02_forces/Exercise_2_10_attractrepel/Attractor.pde
  14. +13 −13 chp02_forces/Exercise_2_10_attractrepel/Mover.pde
  15. +2 −2 chp02_forces/Extra_instantforce/Extra_instantforce.pde
  16. +10 −10 chp02_forces/Extra_instantforce/Mover.pde
  17. +4 −4 chp02_forces/NOC_02forces_many_attraction_3D/Attractor.pde
  18. +10 −10 chp02_forces/NOC_02forces_many_attraction_3D/Mover.pde
  19. +9 −9 chp02_forces/NOC_02forces_many_mutual_boundaries/Mover.pde
  20. +10 −10 chp02_forces/NOC_2_1_forces/Mover.pde
  21. +10 −10 chp02_forces/NOC_2_2_forces_many/Mover.pde
  22. +10 −10 chp02_forces/NOC_2_3_forces_many_realgravity/Mover.pde
  23. +10 −10 chp02_forces/NOC_2_4_forces_friction/Mover.pde
  24. +10 −10 chp02_forces/NOC_2_4_forces_nofriction/Mover.pde
  25. +1 −1 chp02_forces/NOC_2_5_fluidresistance/Liquid.pde
  26. +8 −8 chp02_forces/NOC_2_5_fluidresistance/Mover.pde
  27. +1 −1 chp02_forces/NOC_2_5_fluidresistance_sequence/Liquid.pde
  28. +8 −8 chp02_forces/NOC_2_5_fluidresistance_sequence/Mover.pde
  29. +10 −10 chp02_forces/NOC_2_6_attraction/Attractor.pde
  30. +10 −10 chp02_forces/NOC_2_6_attraction/Mover.pde
  31. +10 −10 chp02_forces/NOC_2_7_attraction_many/Attractor.pde
  32. +4 −4 chp02_forces/NOC_2_7_attraction_many/Mover.pde
  33. +5 −5 chp02_forces/NOC_2_8_mutual_attraction/Mover.pde
  34. +2 −2 chp03_oscillation/AdditiveWave/AdditiveWave.pde
  35. +8 −8 chp03_oscillation/AttractionArrayWithOscillation/Attractor.pde
  36. +5 −5 chp03_oscillation/AttractionArrayWithOscillation/Crawler.pde
  37. +2 −2 chp03_oscillation/AttractionArrayWithOscillation/Oscillator.pde
  38. +4 −4 chp03_oscillation/Exercise_3_02_cannon/CannonBall.pde
  39. +5 −5 chp03_oscillation/Exercise_3_02_cannon/Exercise_3_02_cannon.pde
  40. +1 −1 chp03_oscillation/Exercise_3_05_asteroids/Exercise_3_05_asteroids.pde
  41. +8 −8 chp03_oscillation/Exercise_3_05_asteroids/Spaceship.pde
  42. +2 −2 chp03_oscillation/Exercise_3_10_OOPWave/Wave.pde
  43. +2 −2 chp03_oscillation/Exercise_3_11_AdditiveWave/Exercise_3_11_AdditiveWave.pde
  44. +1 −1 chp03_oscillation/Exercise_3_16_springs/Exercise_3_16_springs.pde
  45. +10 −10 chp03_oscillation/Exercise_3_16_springs/Mover.pde
  46. +4 −4 chp03_oscillation/Exercise_3_16_springs/Spring.pde
  47. +1 −1 chp03_oscillation/Exercise_3_16_springs_array/Exercise_3_16_springs_array.pde
  48. +10 −10 chp03_oscillation/Exercise_3_16_springs_array/Mover.pde
  49. +4 −4 chp03_oscillation/Exercise_3_16_springs_array/Spring.pde
  50. +10 −10 chp03_oscillation/ExtraOscillatingBody/Attractor.pde
  51. +10 −10 chp03_oscillation/ExtraOscillatingBody/Mover.pde
  52. +4 −4 chp03_oscillation/NOC_3_02_forces_angular_motion/Attractor.pde
  53. +4 −4 chp03_oscillation/NOC_3_02_forces_angular_motion/Mover.pde
  54. +13 −13 chp03_oscillation/NOC_3_03_pointing_velocity/Mover.pde
  55. +1 −1 chp03_oscillation/NOC_3_05_simple_harmonic_motion/NOC_3_05_simple_harmonic_motion.pde
  56. +2 −2 chp03_oscillation/NOC_3_09_exercise_additive_wave/NOC_3_09_exercise_additive_wave.pde
  57. +1 −1 chp03_oscillation/NOC_3_10_PendulumExample/NOC_3_10_PendulumExample.pde
  58. +10 −10 chp03_oscillation/NOC_3_10_PendulumExample/Pendulum.pde
  59. +1 −1 chp03_oscillation/NOC_3_10_PendulumExampleSimplified/NOC_3_10_PendulumExampleSimplified.pde
  60. +8 −8 chp03_oscillation/NOC_3_10_PendulumExampleSimplified/Pendulum.pde
  61. +10 −10 chp03_oscillation/NOC_3_11_spring/Mover.pde
  62. +1 −1 chp03_oscillation/NOC_3_11_spring/NOC_3_11_spring.pde
  63. +9 −9 chp03_oscillation/NOC_3_11_spring/Spring.pde
  64. +6 −6 chp03_oscillation/OOPWaveParticles/Particle.pde
  65. +3 −3 chp03_oscillation/OOPWaveParticles/Wave.pde
  66. +5 −5 chp04_systems/Exercise_4_03_MovingParticleSystem/Particle.pde
  67. +2 −2 chp04_systems/Exercise_4_03_MovingParticleSystem/ParticleSystem.pde
  68. +1 −1 chp04_systems/Exercise_4_04_asteroids/Exercise_4_04_asteroids.pde
  69. +5 −5 chp04_systems/Exercise_4_04_asteroids/Particle.pde
  70. +9 −9 chp04_systems/Exercise_4_04_asteroids/Spaceship.pde
  71. +5 −5 chp04_systems/Exercise_4_06_Shatter/Particle.pde
  72. +6 −6 chp04_systems/Exercise_4_10_particleintersection/Particle.pde
  73. +1 −1 chp04_systems/Exercise_4_10_particleintersection/ParticleSystem.pde
  74. +6 −6 chp04_systems/Exercise_4_10_particlerepel/Particle.pde
  75. +1 −1 chp04_systems/Exercise_4_10_particlerepel/ParticleSystem.pde
  76. +4 −4 chp04_systems/Exercise_4_12_ArrayofImages/Particle.pde
  77. +5 −5 chp04_systems/NOC_4_01_SingleParticle/Particle.pde
  78. +5 −5 chp04_systems/NOC_4_01_SingleParticle_trail/Particle.pde
  79. +5 −5 chp04_systems/NOC_4_02_ArrayListParticles/Particle.pde
  80. +5 −5 chp04_systems/NOC_4_03_ParticleSystemClass/Particle.pde
  81. +2 −2 chp04_systems/NOC_4_03_ParticleSystemClass/ParticleSystem.pde
  82. +5 −5 chp04_systems/NOC_4_04_SystemofSystems/Particle.pde
  83. +2 −2 chp04_systems/NOC_4_05_ParticleSystemInheritancePolymorphism/Confetti.pde
  84. +5 −5 chp04_systems/NOC_4_05_ParticleSystemInheritancePolymorphism/Particle.pde
  85. +2 −2 chp04_systems/NOC_4_05_ParticleSystemInheritancePolymorphism/ParticleSystem.pde
  86. +5 −5 chp04_systems/NOC_4_06_ParticleSystemForces/Particle.pde
  87. +2 −2 chp04_systems/NOC_4_06_ParticleSystemForces/ParticleSystem.pde
  88. +5 −5 chp04_systems/NOC_4_07_ParticleSystemForcesRepeller/Particle.pde
  89. +2 −2 chp04_systems/NOC_4_07_ParticleSystemForcesRepeller/ParticleSystem.pde
  90. +5 −5 chp04_systems/NOC_4_07_ParticleSystemForcesRepeller/Repeller.pde
  91. +4 −4 chp04_systems/NOC_4_08_ParticleSystemSmoke/NOC_4_08_ParticleSystemSmoke.pde
  92. +5 −5 chp04_systems/NOC_4_08_ParticleSystemSmoke/Particle.pde
  93. +4 −4 chp04_systems/NOC_4_08_ParticleSystemSmoke_b/NOC_4_08_ParticleSystemSmoke_b.pde
  94. +5 −5 chp04_systems/NOC_4_08_ParticleSystemSmoke_b/Particle.pde
  95. +4 −4 chp04_systems/NOC_4_09_AdditiveBlending/Particle.pde
  96. +5 −5 chp04_systems/ParticleSystemInheritance_pushpop/Particle.pde
  97. +1 −1 chp04_systems/ParticleSystemInheritance_pushpop/ParticleChild.pde
  98. +2 −2 chp04_systems/ParticleSystemInheritance_pushpop/ParticleSystem.pde
  99. +1 −1 chp04_systems/flight404/flight404_particles_1_simple/NOC_gl.pde
  100. +5 −5 chp04_systems/flight404/flight404_particles_1_simple/emitter.pde
  101. +7 −7 chp04_systems/flight404/flight404_particles_1_simple/particle.pde
  102. +3 −3 chp04_systems/flight404/flight404_particles_2_GLtexture/NOC_gl.pde
  103. +2 −2 chp04_systems/flight404/flight404_particles_2_GLtexture/cursor.pde
  104. +7 −7 chp04_systems/flight404/flight404_particles_2_GLtexture/emitter.pde
  105. +1 −1 chp04_systems/flight404/flight404_particles_2_GLtexture/nebula.pde
  106. +1 −1 chp04_systems/flight404/flight404_particles_2_GLtexture/particle.pde
  107. +3 −3 chp04_systems/flight404/flight404_particles_2_simple/NOC_gl.pde
  108. +2 −2 chp04_systems/flight404/flight404_particles_2_simple/cursor.pde
  109. +7 −7 chp04_systems/flight404/flight404_particles_2_simple/emitter.pde
  110. +1 −1 chp04_systems/flight404/flight404_particles_2_simple/nebula.pde
  111. +1 −1 chp04_systems/flight404/flight404_particles_2_simple/particle.pde
  112. +1 −1 chp04_systems/simpleInheritance/Circle.pde
  113. +1 −1 chp04_systems/simplePolymorphism/Circle.pde
  114. +12 −12 chp05_physicslibraries/CollisionsEqualMass/Mover.pde
  115. +3 −3 chp05_physicslibraries/CollisionsEqualMass/drawVector.pde
  116. +2 −2 chp05_physicslibraries/box2d/BlobSkeleton/BlobSkeleton.pde
  117. +4 −4 chp05_physicslibraries/box2d/BlobSkeleton/Spring.pde
  118. +4 −4 chp05_physicslibraries/box2d/CollisionsAndControl/Spring.pde
  119. +4 −4 chp05_physicslibraries/box2d/CollisionsAndControlInterface/Spring.pde
  120. +2 −2 chp05_physicslibraries/box2d/Exercise_5_7_Car/Car.pde
  121. +1 −1 chp05_physicslibraries/box2d/KinematicTest/Box.pde
  122. +2 −2 chp05_physicslibraries/box2d/KinematicTest/KinematicTest.pde
  123. +1 −1 chp05_physicslibraries/box2d/MouseKinematic/Box.pde
  124. +1 −1 chp05_physicslibraries/box2d/MouseKinematic/MouseKinematic.pde
  125. +1 −1 chp05_physicslibraries/box2d/NOC_5_1_box2d_exercise_solved/Box.pde
  126. +1 −1 chp05_physicslibraries/box2d/NOC_5_4_Polygons/Boundary.pde
  127. +1 −1 chp05_physicslibraries/box2d/NOC_5_7_RevoluteJoint/NOC_5_7_RevoluteJoint.pde
  128. +1 −1 chp05_physicslibraries/box2d/NOC_5_7_RevoluteJoint/Windmill.pde
  129. +2 −2 chp05_physicslibraries/box2d/NOC_5_8_MouseJoint/NOC_5_8_MouseJoint.pde
  130. +4 −4 chp05_physicslibraries/box2d/NOC_5_8_MouseJoint/Spring.pde
  131. +2 −2 chp05_physicslibraries/toxiclibs/NOC_5_11_SoftStringPendulum/Chain.pde
  132. +1 −1 chp05_physicslibraries/toxiclibs/NOC_5_11_SoftStringPendulum/NOC_5_11_SoftStringPendulum.pde
  133. +10 −10 chp06_agents/Alignment/Vehicle.pde
  134. +17 −17 chp06_agents/Exercise_6_04_Wander/Vehicle.pde
  135. +2 −2 chp06_agents/Exercise_6_08_FlowField3DNoise/FlowField.pde
  136. +10 −10 chp06_agents/Exercise_6_08_FlowField3DNoise/Vehicle.pde
  137. +5 −5 chp06_agents/Exercise_6_09_AngleBetween/Exercise_6_09_AngleBetween.pde
  138. +21 −21 chp06_agents/Exercise_6_13_CrowdPathFollowing/Vehicle.pde
  139. +21 −21 chp06_agents/Exercise_6_17_View/Boid.pde
  140. +2 −2 chp06_agents/FlowfieldImage/FlowField.pde
  141. +10 −10 chp06_agents/FlowfieldImage/Vehicle.pde
  142. +1 −1 chp06_agents/NOC_6_01_Seek/NOC_6_01_Seek.pde
  143. +6 −6 chp06_agents/NOC_6_01_Seek/Vehicle.pde
  144. +1 −1 chp06_agents/NOC_6_01_Seek_trail/NOC_6_01_Seek_trail.pde
  145. +7 −7 chp06_agents/NOC_6_01_Seek_trail/Vehicle.pde
  146. +1 −1 chp06_agents/NOC_6_02_Arrive/NOC_6_02_Arrive.pde
  147. +6 −6 chp06_agents/NOC_6_02_Arrive/Vehicle.pde
  148. +9 −9 chp06_agents/NOC_6_03_StayWithinWalls/Vehicle.pde
  149. +10 −10 chp06_agents/NOC_6_03_StayWithinWalls_trail/Vehicle.pde
  150. +2 −2 chp06_agents/NOC_6_04_Flow_Figures/FlowField.pde
  151. +10 −10 chp06_agents/NOC_6_04_Flow_Figures/Vehicle.pde
  152. +2 −2 chp06_agents/NOC_6_04_Flowfield/FlowField.pde
  153. +10 −10 chp06_agents/NOC_6_04_Flowfield/Vehicle.pde
  154. +15 −15 chp06_agents/NOC_6_05_PathFollowingSimple/Vehicle.pde
  155. +17 −17 chp06_agents/NOC_6_06_PathFollowing/Vehicle.pde
  156. +11 −11 chp06_agents/NOC_6_07_Separation/Vehicle.pde
  157. +8 −8 chp06_agents/NOC_6_08_SeparationAndSeek/Vehicle.pde
  158. +18 −18 chp06_agents/NOC_6_09_Flocking/Boid.pde
  159. +3 −3 chp06_agents/StayWithinCircle/StayWithinCircle.pde
  160. +10 −10 chp06_agents/StayWithinCircle/Vehicle.pde
  161. +2 −2 chp06_agents/binlatticespatialsubdivision/intersection/intersection/intersection.pde
  162. +15 −15 chp06_agents/box2d/Flocking_box2d/Boid.pde
  163. +13 −13 chp06_agents/flocking_sliders/Boid.pde
  164. +1 −1 chp08_fractals/Exercise_8_06_Tree/Exercise_8_06_Tree.pde
  165. +1 −1 chp08_fractals/Exercise_8_07_Tree/Exercise_8_07_Tree.pde
  166. +4 −4 chp08_fractals/Exercise_8_08_09_TreeArrayListLeaves/Branch.pde
  167. +1 −1 chp08_fractals/Exercise_8_08_09_TreeArrayListLeaves/Exercise_8_08_09_TreeArrayListLeaves.pde
  168. +2 −2 chp08_fractals/Exercise_8_08_09_TreeArrayListLeaves/Leaf.pde
  169. +1 −1 chp08_fractals/Figure_8_20_Tree/Figure_8_20_Tree.pde
  170. +1 −1 chp08_fractals/NOC_8_04_Tree/NOC_8_04_Tree.pde
  171. +1 −1 chp08_fractals/NOC_8_06_Tree/NOC_8_06_Tree.pde
  172. +1 −1 chp08_fractals/NOC_8_06_Tree_static/NOC_8_06_Tree_static.pde
  173. +12 −19 chp08_fractals/NOC_8_09_LSystem/Turtle.pde
  174. +2 −2 chp09_ga/EvolveFlowField/DNA.pde
  175. +3 −3 chp09_ga/EvolveFlowField/EvolveFlowField.pde
  176. +1 −1 chp09_ga/EvolveFlowField/Obstacle.pde
  177. +4 −4 chp09_ga/EvolveFlowField/Population.pde
  178. +14 −14 chp09_ga/EvolveFlowField/Rocket.pde
  179. +2 −2 chp09_ga/NOC_9_02_SmartRockets_superbasic/NOC_9_02_SmartRockets_superbasic.pde
  180. +4 −4 chp09_ga/NOC_9_02_SmartRockets_superbasic/Population.pde
  181. +6 −6 chp09_ga/NOC_9_02_SmartRockets_superbasic/Rocket.pde
  182. +4 −4 chp09_ga/NOC_9_03_SmartRockets/NOC_9_03_SmartRockets.pde
  183. +5 −5 chp09_ga/NOC_9_03_SmartRockets/Obstacle.pde
  184. +4 −4 chp09_ga/NOC_9_03_SmartRockets/Population.pde
  185. +7 −7 chp09_ga/NOC_9_03_SmartRockets/Rocket.pde
  186. +12 −12 chp09_ga/NOC_9_05_EvolutionEcosystem/Bloop.pde
  187. +1 −1 chp09_ga/NOC_9_05_EvolutionEcosystem/Food.pde
  188. +1 −1 chp09_ga/NOC_9_05_EvolutionEcosystem/World.pde
  189. +5 −5 chp10_nn/Exercise_10_5_LayeredNetworkAnimation/Connection.pde
  190. +3 −3 chp10_nn/Exercise_10_5_LayeredNetworkAnimation/Network.pde
  191. +4 −4 chp10_nn/Exercise_10_5_LayeredNetworkAnimation/Neuron.pde
  192. +1 −1 chp10_nn/LayeredNetworkViz/Connection.pde
  193. +3 −3 chp10_nn/LayeredNetworkViz/Network.pde
  194. +3 −3 chp10_nn/LayeredNetworkViz/Neuron.pde
  195. +1 −1 chp10_nn/NOC_10_02_SeekingNeural/NOC_10_02_SeekingNeural.pde
  196. +9 −9 chp10_nn/NOC_10_02_SeekingNeural/Vehicle.pde
  197. +1 −1 chp10_nn/NOC_10_03_NetworkViz/Connection.pde
  198. +3 −3 chp10_nn/NOC_10_03_NetworkViz/Network.pde
  199. +4 −4 chp10_nn/NOC_10_03_NetworkViz/Neuron.pde
  200. +5 −5 chp10_nn/NOC_10_04_NetworkAnimation/Connection.pde
  201. +3 −3 chp10_nn/NOC_10_04_NetworkAnimation/Network.pde
  202. +4 −4 chp10_nn/NOC_10_04_NetworkAnimation/Neuron.pde
  203. +2 −2 introduction/Gaussian2/Gaussian2.pde
  204. +1 −1 introduction/NOC_I_4_Gaussian/NOC_I_4_Gaussian.pde
  205. +5 −5 introduction/NOC_I_5_NoiseWalk/Walker.pde
  206. +7 −7 introduction/NoiseWalkAcceleration/Walker.pde
  207. +7 −7 introduction/NoiseWalkVelocity/Walker.pde
  208. +5 −5 introduction/NoiseWalk_Many/Walker.pde
  209. +5 −5 introduction/RandomWalkPVector/Walker.pde
  210. +7 −7 introduction/RandomWalkTrail/Walker.pde
  211. +1 −1 introduction/SimpleProbablility/SimpleProbablility.pde
@@ -4,41 +4,41 @@
class Mover {
- // The Mover tracks location, velocity, and acceleration
- PVector location;
+ // The Mover tracks position, velocity, and acceleration
+ PVector position;
PVector velocity;
PVector acceleration;
// The Mover's maximum speed
float topspeed;
Mover() {
// Start in the center
- location = new PVector(width/2,height/2);
+ position = new PVector(width/2,height/2);
velocity = new PVector(0,0);
topspeed = 5;
}
void update() {
- // Compute a vector that points from location to mouse
+ // Compute a vector that points from position to mouse
PVector mouse = new PVector(mouseX,mouseY);
- PVector acceleration = PVector.sub(mouse,location);
+ PVector acceleration = PVector.sub(mouse,position);
// Set magnitude of acceleration
acceleration.setMag(0.2);
// Velocity changes according to acceleration
velocity.add(acceleration);
// Limit the velocity by topspeed
velocity.limit(topspeed);
- // Location changes by velocity
- location.add(velocity);
+ // position changes by velocity
+ position.add(velocity);
}
void display() {
stroke(0);
strokeWeight(2);
fill(127);
- ellipse(location.x,location.y,48,48);
+ ellipse(position.x,position.y,48,48);
}
}
@@ -13,7 +13,7 @@ void setup() {
void draw() {
background(255);
- // Update the location
+ // Update the position
mover.update();
// Display the Mover
mover.display();
@@ -4,25 +4,25 @@
class Mover {
- // The Mover tracks location, velocity, and acceleration
- PVector location;
+ // The Mover tracks position, velocity, and acceleration
+ PVector position;
PVector velocity;
PVector acceleration;
// The Mover's maximum speed
float topspeed;
Mover() {
// Start in the center
- location = new PVector(random(width),random(height));
+ position = new PVector(random(width),random(height));
velocity = new PVector(0,0);
topspeed = 5;
}
void update() {
- // Compute a vector that points from location to mouse
+ // Compute a vector that points from position to mouse
PVector mouse = new PVector(mouseX,mouseY);
- acceleration = PVector.sub(mouse,location);
+ acceleration = PVector.sub(mouse,position);
// Set magnitude of acceleration
//acceleration.setMag(0.2);
acceleration.normalize();
@@ -32,15 +32,15 @@ class Mover {
velocity.add(acceleration);
// Limit the velocity by topspeed
velocity.limit(topspeed);
- // Location changes by velocity
- location.add(velocity);
+ // position changes by velocity
+ position.add(velocity);
}
void display() {
stroke(0);
strokeWeight(2);
fill(127,200);
- ellipse(location.x,location.y,48,48);
+ ellipse(position.x,position.y,48,48);
}
}
@@ -3,7 +3,7 @@
// http://natureofcode.com
// Demonstration of the basics of motion with vector.
-// A "Mover" object stores location, velocity, and acceleration as vectors
+// A "Mover" object stores position, velocity, and acceleration as vectors
// The motion is controlled by affecting the acceleration (in this case towards the mouse)
Mover[] movers = new Mover[20];
@@ -17,7 +17,7 @@ void draw() {
background(255);
- // Add the current speed to the location.
+ // Add the current speed to the position.
x = x + xspeed;
y = y + yspeed;
@@ -29,7 +29,7 @@ void draw() {
}
- // Display circle at x location
+ // Display circle at x position
stroke(0);
strokeWeight(2);
fill(127);
@@ -3,13 +3,13 @@
// http://natureofcode.com
// Example 1-2: Bouncing Ball, with PVector!
-PVector location;
+PVector position;
PVector velocity;
void setup() {
size(200,200);
background(255);
- location = new PVector(100,100);
+ position = new PVector(100,100);
velocity = new PVector(2.5,5);
}
@@ -18,20 +18,20 @@ void draw() {
fill(255,10);
rect(0,0,width,height);
- // Add the current speed to the location.
- location.add(velocity);
+ // Add the current speed to the position.
+ position.add(velocity);
- if ((location.x > width) || (location.x < 0)) {
+ if ((position.x > width) || (position.x < 0)) {
velocity.x = velocity.x * -1;
}
- if ((location.y > height) || (location.y < 0)) {
+ if ((position.y > height) || (position.y < 0)) {
velocity.y = velocity.y * -1;
}
- // Display circle at x location
+ // Display circle at x position
stroke(0);
fill(175);
- ellipse(location.x,location.y,16,16);
+ ellipse(position.x,position.y,16,16);
}
@@ -1,27 +1,27 @@
class Ball {
- PVector location;
+ PVector position;
PVector velocity;
Ball() {
- location = new PVector(100, 100);
+ position = new PVector(100, 100);
velocity = new PVector(2.5, 5);
}
void update() {
- // Add the current speed to the location.
- location.add(velocity);
- if ((location.x > width) || (location.x < 0)) {
+ // Add the current speed to the position.
+ position.add(velocity);
+ if ((position.x > width) || (position.x < 0)) {
velocity.x = velocity.x * -1;
}
- if ((location.y > height) || (location.y < 0)) {
+ if ((position.y > height) || (position.y < 0)) {
velocity.y = velocity.y * -1;
}
}
void display() {
- // Display circle at x location
+ // Display circle at x position
stroke(0);
fill(175);
- ellipse(location.x, location.y, 16, 16);
+ ellipse(position.x, position.y, 16, 16);
}
}
@@ -5,21 +5,18 @@
// Example 1-3: Vector subtraction
void setup() {
- size(640,360);
+ size(640, 360);
}
void draw() {
background(255);
-
- PVector mouse = new PVector(mouseX,mouseY);
- PVector center = new PVector(width/2,height/2);
+
+ PVector mouse = new PVector(mouseX, mouseY);
+ PVector center = new PVector(width/2, height/2);
mouse.sub(center);
-
- translate(width/2,height/2);
+
+ translate(width/2, height/2);
strokeWeight(2);
stroke(0);
- line(0,0,mouse.x,mouse.y);
-
-}
-
-
+ line(0, 0, mouse.x, mouse.y);
+}
@@ -12,7 +12,7 @@ void setup() {
void draw() {
background(255);
- // A vector that points to the mouse location
+ // A vector that points to the mouse position
PVector mouse = new PVector(mouseX,mouseY);
// A vector that points to the center of the window
PVector center = new PVector(width/2,height/2);
@@ -4,39 +4,39 @@
class Mover {
- PVector location;
+ PVector position;
PVector velocity;
Mover() {
- location = new PVector(random(width), random(height));
+ position = new PVector(random(width), random(height));
velocity = new PVector(random(-2, 2), random(-2, 2));
}
void update() {
- location.add(velocity);
+ position.add(velocity);
}
void display() {
stroke(0);
strokeWeight(2);
fill(127);
- ellipse(location.x, location.y, 48, 48);
+ ellipse(position.x, position.y, 48, 48);
}
void checkEdges() {
- if (location.x > width) {
- location.x = 0;
+ if (position.x > width) {
+ position.x = 0;
}
- else if (location.x < 0) {
- location.x = width;
+ else if (position.x < 0) {
+ position.x = width;
}
- if (location.y > height) {
- location.y = 0;
+ if (position.y > height) {
+ position.y = 0;
}
- else if (location.y < 0) {
- location.y = height;
+ else if (position.y < 0) {
+ position.y = height;
}
}
}
@@ -4,13 +4,13 @@
class Mover {
- PVector location;
+ PVector position;
PVector velocity;
PVector acceleration;
float topspeed;
Mover() {
- location = new PVector(width/2, height/2);
+ position = new PVector(width/2, height/2);
velocity = new PVector(0, 0);
acceleration = new PVector(-0.001, 0.01);
topspeed = 10;
@@ -19,30 +19,30 @@ class Mover {
void update() {
velocity.add(acceleration);
velocity.limit(topspeed);
- location.add(velocity);
+ position.add(velocity);
}
void display() {
stroke(0);
strokeWeight(2);
fill(127);
- ellipse(location.x, location.y, 48, 48);
+ ellipse(position.x, position.y, 48, 48);
}
void checkEdges() {
- if (location.x > width) {
- location.x = 0;
+ if (position.x > width) {
+ position.x = 0;
}
- else if (location.x < 0) {
- location.x = width;
+ else if (position.x < 0) {
+ position.x = width;
}
- if (location.y > height) {
- location.y = 0;
+ if (position.y > height) {
+ position.y = 0;
}
- else if (location.y < 0) {
- location.y = height;
+ else if (position.y < 0) {
+ position.y = height;
}
}
}
Oops, something went wrong.

0 comments on commit 4195df9

Please sign in to comment.