View on GitHub

idmd

Bush School Interactive Digital Media Design Course

Bush School IDMD Spring Semester 2021

Week 1 Exercise

Building a Robot

Goal

This exercise is designed to explain the difference between a static program and a dynamic program and to practice using the Processing language by coloring a robot.

Part 1: Color The Robot

The Code

Note: It is an image, as we would like you to practice typing out the code.

alt text

Need help?

These steps will help you color your robot

Part 2: Make The Robot Program Dynamic

The program you have written so far is static. The code runs, draws your beautiful robot, and then quits.

We want it to be active (keep running) and make our robot move. Notice the program shown below, this is a dynamic version. The new code groups the instructions for the robot into two functions, the setup() function and the draw() function. Tip: In programming, functions are written with a pair of parentheses after the name. You should make the highlighted changes to your code.

alt text

What is happening?

The setup() function runs once, when the program is first run. After the setup() runs, then the draw() function runs over and over again. This redraws the image. The diagram shows what is happening when the Processing engine runs a dynamic program.

alt text

The way to read this diagram is first setup is called and finishes, then draw is run and finishes, and then draw is called and runs again and finishes again, again and again …. Until you stop the program or turn off your computer”

Part 3: Move the Robot

Add two more instructions to your dynamic program at the top of your draw function.

The instructions go inside of draw() – right after the draw() function and before the // Neck comment. Caution: Notice that “mouse” is written in lowercase letters, and the X and Y are uppercase; this is required. After adding the code run your program and move your mouse.

alt text

Part 4: Lots of Robots!

Remove background(205); from your program, and run it again. Add a block comment at the top of your program that clearly explains what is happening when you remove the background line of code and what happens when you put it back in. Need help understanding this? Reach out to us!

Submission

Make sure your code has the background call added back in before submitting and add this project to your github portfolio.

Extra Challenge

If you want to challenge yourself with this project try out any of the items below

Reference

Online Book Reference: 1. Getting Started with Processing Study the 1st 3 chapters.