-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonsConnect.pde
81 lines (65 loc) · 1.54 KB
/
MonsConnect.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
79
80
import processing.video.*;
import SimpleOpenNI.*;
Capture video;
PImage webcamImage;
int sceneWidth = 1280;
int sceneHeight = 720;
PShape header;
int delayAfterWinning = 100;
int winningDelay = 0;
static int videoWidth = 1280;
static int videoHeight = 720;
void captureEvent(Capture video) {
video.read();
}
//Generate a SimpleOpenNI object
SimpleOpenNI kinect;
void setup() {
background(0, 0, 0);
loadCharacters();
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
kinect.enableRGB();
kinect.enableUser();// because of the version this change
size(1280, 720);
fill(0, 0, 0);
kinect.setMirror(true);
video = new Capture(this, 1280, 720);
// Step 4. Start the capturing process.
video.start();
loadMask(currentCharacter);
loadStartupAnimation();
loadLogoAnimation();
loadEndImage(currentCharacter);
}
void draw() {
kinect.update();
frameRate(20);
fill(0, 0, 0);
pushMatrix(); // just so nothing else is affected
scale(-1, 1);
image(video, -video.width, 0);
popMatrix();
//We display start animation only if game didn't started
fill(0, 0, 0);
if (didPlayerWon) {
currentCharacter =0;
displayEndImage();
if (winningDelay < delayAfterWinning) {
winningDelay++;
} else {
didPlayerWon = false;
displayStartupAnimation();
didGameStarted = false;
winningDelay = 0;
currentCharacter = 0;
}
} else {
displayMask();
startDetection(kinect);
if (!didGameStarted) {
displayStartupAnimation();
}
displayLogoAnimation();
}
}