Programming for Poets 2010-05-06: Difference between revisions

From Noisebridge
Jump to navigation Jump to search
(Created page with 'We began with the"getting started" tutorial http://processing.org/learning/gettingstarted/ We covered a little about *coordinate system *variables *program flow *functions An…')
 
No edit summary
Line 20: Line 20:
   
   
  void draw() {
  void draw() {
       // this is a comment
       // draw with a gray border
       stroke(128,128,128);
       stroke(128,128,128);
         // draw over the box we drew last time (at old mouse pos)
         // draw over the box we drew last time (at old mouse pos)

Revision as of 14:27, 11 May 2010

We began with the"getting started" tutorial

http://processing.org/learning/gettingstarted/

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
      background(128);
} 

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

      fill(255); //white
      // draw the new box at the new mouse position
      drawbox(mouseX,mouseY);
}

// draw a paddle-shaped box at the given coordinates
void drawbox(int x, int y) {
     rect(30,y,10,40);
}