Creating a Simple Gravity Script in Scratch

Welcome back! In this tutorial we will be creating an "egg bounce" to simulate a gravity script. We will be utilizing two broadcasting scripts to bounce up and down with the sprite. 

Objective: To learn about gravity physics scripts and broadcasting. This lesson also focuses on the "repeat until" block. 

Final Product: 

Graphic Template: (the "see inside" button will pull up the programming interface)

Physics: The physics in this lesson is based on the first two kinematic equations from the AP Physics 1 equation sheet. 

These two equations essentially relate position (where you are in space), velocity (how fast you are moving) and acceleration (how quickly you are speeding up). You can think about how this applies when are traveling in a car (position of the car, speed of the car and acceleration of the car). When you are for example traveling at a constant 55 mph down the highway, you are traveling at constant velocity and zero acceleration. When you are entering and exiting the highway you are either experience a considerable amount of acceleration or deceleration. 

Gravity on earth is roughly 9.8 m/s^2 towards earth (this is why an object like a ball thrown up in the air returns to earth). The numbers I used a roughly analogous to those on earth but they don't really have the same meaning in the context of the Scratch stage. Here the positive/distance is measured in x and y coordinates. As we go over in this lecture, the dimensions of the stage are -180 to 180 in the y-direction and -240 to 240 in the x-direction. This is context in which the sprites are traveling. I encourage you to change the different values and see how that impacts the "gravity script" of the sprite.


Bounce up/bounce down loop scripts.
Tips: Make sure that you are bouncing between the correct messages. Remember that you need to place to egg on the screen by clicking before it will bounce up and down. 

Completed Program: Link