-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch.js
More file actions
32 lines (27 loc) · 862 Bytes
/
sketch.js
File metadata and controls
32 lines (27 loc) · 862 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
26
27
28
29
30
31
32
var movingrect,fixedrect;
function setup() {
createCanvas(800,400);
movingrect = createSprite(400, 200, 50, 50);
movingrect.shapeColor = "green";
movingrect.debug = "true";
fixedrect = createSprite(400,100,50,100);
fixedrect.shapeColor = "green";
fixedrect.debug = "true";
}
function draw() {
background(0);
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&&
movingrect.y-fixedrect.y<= movingrect.height/2+fixedrect.height/2 &&
fixedrect.y-movingrect.y <= movingrect.height/2+fixedrect.height/2){
movingrect.shapeColor = "red";
fixedrect.shapeColor = "red";
}
else{
movingrect.shapeColor = "green";
fixedrect.shapeColor = "green";
}
drawSprites();
}