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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
testsong=new song("VODA_MUS_DeckTheHalls-Backing_v.1.5.mp3","VODA_MUS_DeckTheHalls-Melody_v.1.5.mp3","MIDI_DeckTheHalls_MIDI.1.5.xml","Lyrics_DeckTheHalls.1.5.xml","Levels_DeckTheHalls.1.5.xml");
testsong->setTimeframe(2500);
testsong->setFlakeThresh(1000,100);
ofSetBackgroundAuto(false);
ofBackground(0,0,0);
/*
for (int i=0;i<3;i++) penguins.push_back(Animal());
penguins[0].load("Penguin-Blue.xml");
penguins[1].load("Penguin-Purple.xml");
penguins[2].load("Penguin-Green.xml");
for (int i=0;i<3;i++) raccoons.push_back(Animal());
raccoons[0].load("Raccoon-Blue.xml");
raccoons[1].load("Raccoon-Purple.xml");
raccoons[2].load("Raccoon-Green.xml");
*/
loadanimals("Penguins");
playanimal =&playanimals;
//testpenguin.load("Penguin-Blue.xml");
//debug: commented out: 436m 257m
//508fr 1.7s load in use: 837m 444m
//release: commented out: 436m 256m
//508fr 1.4s load in use: 836m 443m
background.loadMovie("Background_v3.mp4");
background.setLoopState(OF_LOOP_NORMAL);
background.play();
vignette.loadImage("Vignette.png");
showFPS=false;
}
void testApp::loadanimals(string which) {
playanimals.clear();
for (int i=0;i<3;i++) playanimals.push_back(Animal());
if (which=="Penguins") {
playanimals[0].load("Penguin-Blue.xml");
playanimals[1].load("Penguin-Purple.xml");
playanimals[2].load("Penguin-Green.xml");
}
else {
playanimals[0].load("Raccoon-Blue.xml");
playanimals[1].load("Raccoon-Purple.xml");
playanimals[2].load("Raccoon-Green.xml");
}
}
void testApp::exit(){
delete testsong;
}
//--------------------------------------------------------------
void testApp::update(){
int ret=game.update();
if (ret==1000) {
testsong->preRoll(250);
}
else if (ret>0) {
testsong->playerControl(ret);
(*playanimal)[ret-1].playNow("Clap");
}
for (int i=0;i<3;i++) {
(*playanimal)[i].update();
}
background.update();
}
//--------------------------------------------------------------
void testApp::draw(){
ofDisableAlphaBlending();
ofSetColor(255,255,255);
background.draw(0,0,ofGetWidth(),ofGetHeight());
float scale=ofGetHeight()/1080.0f;
ofEnableAlphaBlending();
vignette.draw(0,0,ofGetWidth(),ofGetHeight());
//ofBackground(0,0,0,0.1);
/*
ofSetColor(0,0,0,100);
ofRect(0,0,ofGetWidth(),ofGetHeight());
*/
if (testsong->isPlaying) {
ofSetColor(255,255,255);
testsong->drawNotes();
int missed=testsong->missedNote();
if (missed>-1) (*playanimal)[missed].playNow("Shudder");
int hit=testsong->hitNote();
if (hit>-1) (*playanimal)[hit].play("Catch");
}
ofSetColor(255,255,255);
for (int i=0;i<3;i++) (*playanimal)[i].draw(gridX[i]*ofGetWidth(),gridY[0]*ofGetHeight(),scale);
if (testsong->isPlaying) {
ofSetColor(255,255,255);
testsong->draw();
}
else ofDrawBitmapString("game over!", (ofGetWidth()/2)-25,(ofGetHeight()/2)-5);
if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate()), ofGetWidth()-50,ofGetHeight()-15);
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
switch (key) {
case ' ':
if (!testsong->isPlaying) {
testsong->preRoll(250);
}
break;
case '1':
case '2':
case '3':
testsong->playerControl(key-'1');
(*playanimal)[key-'1'].playNow("Clap");
break;
case 's':
game.startGame();
break;
case 'f':
showFPS=!showFPS;
break;
case 'r':
loadanimals("Raccoons");
break;
case 'p':
loadanimals("Penguins");
break;
}
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
switch (key) {
case '1':
case '2':
case '3':
break;
}
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
|