-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
53 lines (52 loc) · 1.38 KB
/
sketch.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var gameObject1,movingrect,gameObject2,gameObject3,gameObject;
function setup() {
createCanvas(1200,800);
gameObject1=createSprite(100, 100, 50, 50);
gameObject1.shapeColor="green";
gameObject2=createSprite(300, 100, 50, 50);
gameObject2.shapeColor="green";
gameObject3=createSprite(500, 100, 50, 50);
gameObject3.shapeColor="green";
gameObject4=createSprite(700, 100, 50, 50);
gameObject4.shapeColor="green";
movingrect=createSprite(400,200,80,30);
movingrect.shapeColor="green";
}
function draw() {
background(0,0,0);
movingrect.x=World.mouseX;
movingrect.y=World.mouseY;
if(isTouching(movingrect,gameObject1)) {
movingrect.shapeColor="red";
gameObject1.shapeColor="red";
}
else{
movingrect.shapeColor="green";
gameObject1.shapeColor="green";
}
if(isTouching(movingrect,gameObject2)) {
movingrect.shapeColor="red";
gameObject2.shapeColor="red";
}
else{
movingrect.shapeColor="green";
gameObject2.shapeColor="green";
}
if(isTouching(movingrect,gameObject3)) {
movingrect.shapeColor="red";
gameObject3.shapeColor="red";
}
else{
movingrect.shapeColor="green";
gameObject3.shapeColor="green";
}
if(isTouching(movingrect,gameObject4)) {
movingrect.shapeColor="red";
gameObject4.shapeColor="red";
}
else{
movingrect.shapeColor="green";
gameObject4.shapeColor="green";
}
drawSprites();
}