Coding to Simulate Gravity

Grades-Middle School and up but can be differentiated for 4th grade up

As an elementary teacher I like to highlight teaching practices in elementary rather than Middle and High School but this application of coding is too good not to highlight. Also, it can be a great way to challenge Elementary kids.  I recently challenged one of my 4th graders with this and he was able to complete it at an elementary level. He loved the challenge.

Lesson:

Challenge: Figure out how to make the ball drop look realistic.  Here is a video to use for reference

 

Steps:

  1. Download the dropball starter program below
  2. Create a ball script for “drop” that makes the ball fall to the grass and stop
  3. Check the video to see if your motion looks realistic
  4. Check Newton’s Laws to see if your motion obeys the laws of physics
  5. BONUS – make the ball bounce

Lesson from Brian Foley. Check out his site for many more fantastic lessons and resources on how to teach physics through coding.

Thoughts:  Students constantly experienceball-motion the laws of physics all around them. But when they have to code a world into reality they are forced to think about those laws of physics.  Such as Newtons first law: an object at rest tends to stay at rest, and an object in motion tends to stay in motion.

When a student codes a car moving across the screen the car won’t move until they write a command that triggers that movement and the car won’t stop moving across the screen unless there is a command that stops the movement.car-moving

Think about how much physics is involved when students try to create a Mario type platforming game which requires gravity effect.  Or what about when students make an Angry Birds type game. There is velocity and gravity involved along with angles and force. They not only have to think about what happens in the real world but they have to figure out the mathematical formula which will make that same effect on their computer screen.  That is the power of coding.

Refer to Scratch wiki to see how you can simulate gravity using physics

4th grader’s explanation of how he created the  “ball effect”.