-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch.js
More file actions
25 lines (21 loc) · 810 Bytes
/
Copy pathsketch.js
File metadata and controls
25 lines (21 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var movingRect, fixedRect;
function setup() {
createCanvas(800,400);
movingRect = createSprite(20, 20, 20, 20);
fixedRect = createSprite(400, 200, 70, 50);
movingRect.shapeColor = "blue";
fixedRect.shapeColor ="yellow";
}
function draw() {
background(255,255,255);
movingRect.x = World.mouseX;
movingRect.y = World.mouseY;
if(movingRect.x - fixedRect.x < movingRect.width/2 + fixedRect.width/2 && fixedRect.x - movingRect.x < movingRect.width/2 + fixedRect.width/2 && fixedRect.y - movingRect.y < movingRect.height/2 + fixedRect.height/2 && movingRect.y - fixedRect.y < movingRect.height/2 + fixedRect.height/2){
movingRect.shapeColor = "red";
fixedRect.shapeColor = "green";
}else{
movingRect.shapeColor = "blue";
fixedRect.shapeColor ="yellow";
}
drawSprites();
}