Programming for Poets 2010-05-06

From Noisebridge
(Redirected from 2010-05-06)
Jump to: navigation, search

We began with the"getting started" tutorial

We covered a little about

  • coordinate system
  • variables
  • program flow
  • functions

And finished by editing a simple "pong paddle" program:

void setup() {
      // size of our drawing window
      size(400, 400);
      // set the background color to gray

void draw() {
      // draw with a gray border
       // draw over the box we drew last time (at old mouse pos)
      fill(128); // gray

      fill(255); //white
      // draw the new box at the new mouse position

// draw a paddle-shaped box at the given coordinates
void drawbox(int x, int y) {

Suggested homework: The position of your pong paddle is controlled by the y variable. Make the color of your paddle change with the x position.

[If you want to learn more about color, this is a *great* explanation: What happens when you use colorMode(HSB,255)?

Extra credit: make a happy face follow the mouse using the ellipse() and arc() functions. It will help to look up arc() in the reference.