Skip to content

Commit

Permalink
sketch.js
Browse files Browse the repository at this point in the history
  • Loading branch information
giovanna-arnoud authored May 22, 2024
1 parent a9638e5 commit 5920e03
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions sketch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
let cor;
let posicaoHorizontal; // x
let posicaoVertical; // y

function setup() {
createCanvas(400, 400);
background(color(100, 0, 190));
cor = color(random(0, 255), random(0, 255), random(0, 255));
posicaoHorizontal = 200;
posicaoVertical = 200;
}

function draw() {
fill(cor);
circle(posicaoHorizontal, posicaoVertical, 50);

if (mouseX < posicaoHorizontal) {
posicaoHorizontal = posicaoHorizontal - 1;
}

if (mouseX > posicaoHorizontal) {
posicaoHorizontal = posicaoHorizontal + 1;
}

if (mouseY < posicaoVertical) {
posicaoVertical--;
}

if (mouseY > posicaoVertical) {
posicaoVertical++;
}

if (mouseIsPressed) {
cor = color(random(0, 255), random(0, 255), random(0, 255), random(0, 100));
}
}

0 comments on commit 5920e03

Please sign in to comment.