-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch.js
More file actions
46 lines (35 loc) · 992 Bytes
/
sketch.js
File metadata and controls
46 lines (35 loc) · 992 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var movingrect, fixedrect;
var pickle, pikachu, mariam, molly;
function setup() {
//creates the canvas
createCanvas(800, 400);
movingrect = createSprite(400, 200, 50, 50);
movingrect.shapeColor = "red";
movingrect.debug = true;
fixedrect = createSprite(300, 300, 50, 50);
fixedrect.shapeColor = "black";
fixedrect.debug = true;
pickle = createSprite(13, 13, 50,50);
pickle.shapeColor = "crimson";
pikachu = createSprite(250, 250, 50, 50);
pikachu.shapeColor = "cyan";
mariam = createSprite(530,220,50,50);
mariam.shapeColor = "orange";
molly = createSprite(400,330,50,50);
molly.shapeColor = "yellow";
}
function draw() {
//to add color and clear the screen
background("powderblue");
movingrect.x = World.mouseX;
movingrect.y = World.mouseY;
if (isTouching(movingrect, mariam)){
movingrect.shapeColor = "pink";
mariam.shapeColor = "purple";
}
else{
movingrect.shapeColor = "red";
mariam.shapeColor = "orange";
}
drawSprites();
}