-
Notifications
You must be signed in to change notification settings - Fork 0
/
Notification.pde
78 lines (58 loc) · 1.96 KB
/
Notification.pde
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// NOTIFICATION OBJECT ------------------------------------------------------------------------------------------------------------
class Notification {
public PImage notification;
private float xpos;
private float ypos;
private float wid;
private float len;
private SoundFile soundEffect;
private int sensorValue; // this is the sensor index for Arduino!
// Constructor -----------------------------------------------------------------------------------
Notification(float xp, float yp, float w, float l, PImage image, SoundFile effect, int sensor) { // Takes the same 4 arguments as an image would
xpos = xp; // Sets arguments as class parameters
ypos = yp;
wid = w;
len = l;
notification = image; // Load image
soundEffect = effect; //load Sound Effect
sensorValue = sensor;
}
// GETTERS ---------------------------------------------------------------------------------------
float getXPos() {
return xpos;
}
float getYPos() {
return ypos;
}
float getWidth() {
return wid;
}
float getLength() {
return len;
}
float getSensorValue() {
return sensorValue;
}
// SETTERS
void setXPos(float xCoord) {
xpos = xCoord;
}
void setYPos(float yCoord) {
ypos = yCoord;
}
// DRAW NOTIFICATION FUNCTION ----------------------------------------------------------------------
void drawNotification() {
image(notification, xpos, ypos, wid, len); // Draw 'notification' at (xpos, ypos) with dimensions (wid/len)
}
boolean checkIfClicked()
{
// check mouse is in range of the notification
return (mouseX >= xpos) && (mouseX <= xpos + wid) && (mouseY >= ypos) && (mouseY <= ypos + len);
}
//play notification sound
void playNotification(int firstTime){
if ((soundEffect.isPlaying() == false) && (firstTime == 1)){
soundEffect.play();
}
}
}