gauthiier 547bb5b722 typo
2023-01-09 11:06:34 +01:00

1.3 KiB

Basics 101

autopilot creativity

Sketch: 0. Hello World

// Hello world! 
// This is a comment

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  print("Hello World");          // see the console below ↓
}

Sketch: 1.0 Key Events

// Key Events!

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  // Only when keyIsPressed? 
  print("Hello World");
}

// Reference: https://p5js.org/reference/

Sketch: 1.1 Mouse Events

// Mouse Events!

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  if(mouseIsPressed) {
    print("Pressed: " + mouseX + " - " + mouseY) ;          // see the console below ↓  
  }
}

// this is a special p5 function
function mouseMoved() {   
  print("Moved: " + mouseX + " - " + mouseY) ;              // see the console below ↓  
}

// Reference: https://p5js.org/reference/