Facebook
From joe, 1 Year ago, written in JavaScript.
This paste is a reply to Re: Untitled from Idiotic Sloth - go back
Embed
Viewing differences between Re: Untitled and Re:dingdong
let x = 320;
let y = 180;
let xspeed = 5;
let yspeed = 2;

let r = 25;

function setup() {
  createCanvas(640, 360);
}

function draw() {
  background(0);
  
  
  let d = dist(x, y, mouseX, mouseY);
  if(d > 25){
    fill(255,0,0)
  }else{
    fill(0,0,255)
  }
  ellipse(x, y, r*2, r*2);
  
  
  // console.log(d)
  x += xspeed;
  y += yspeed;
  if (x > width - r || x < r) {
    xspeed = -xspeed;
  }
  if (y > height - r || y < r) {
    yspeed = -yspeed;
  }


}