xxxxxxxxxx
ArrayList < note > sheetie = new ArrayList < note > ();
bool started;
int tick;
int score;
int misses;
void setup() {
fullScreen();
background(0, 0, 0);
frameRate(60);
}
void draw() {
noStroke();
fill(0, 0, 0, 50);
rect(0, 0, width, height);
stroke(220, 220, 220);
strokeWeight(10);
fill(230, 230, 230);
// hitboxes should be 225 to 625 (400 width)
ellipse(width / 2 - 300 + sin(tick / 10) * 25, 225 + cos(tick / 10) * 25, 200, 200);
ellipse(width / 2 - 100 + sin(tick / 10) * 25, 225 + cos((tick + 2) / 10) * 25, 200, 200);
ellipse(width / 2 + 100 + sin(tick / 10) * 25, 225 + cos((tick + 4) / 10) * 25, 200, 200);
ellipse(width / 2 + 300 + sin(tick / 10) * 25, 225 + cos((tick + 6) / 10) * 25, 200, 200);
textSize(128);
textAlign(LEFT, TOP);
fill(230, 230, 230);
text("Score: " + score, 0, 0);
textAlign(RIGHT, BOTTOM);
text("Misses: " + misses, width, height);
if (started) {
for (note not: sheetie) {
not.render();
}
if (tick % 5 == 0 && random(4) < 1) {
sheetie.add(new note());
if (random(7) < 1) {
sheetie.add(new note());
}
}
} else {
textAlign(CENTER, CENTER);
text("Press to play", width / 2, height / 2);
}
tick++;
}
class note {
float xPos, yPos;
int randy = round(random(3));
str id;
color colour;
note() {
xPos = width / 2 + (randy * 200 - 300);
yPos = height + 150;
id = "aswd".charAt(randy);
}
void render() {
if (randy == 0) {
colour = color(125, 50, 130);
} else if (randy == 1) {
colour = color(25, 50, 220);
} else if (randy == 2) {
colour = color(25, 220, 50);
} else if (randy == 3) {
colour = color(220, 50, 25);
}
fill(colour);
stroke(lerpColor(colour, color(255, 255, 255), 50));
strokeWeight(5);
textSize(128);
textAlign(CENTER, CENTER);
ellipse(xPos + sin(tick / 10) * 25, yPos, 150, 150);
fill(60, 60, 60);
text(id, xPos + sin(tick / 10) * 25, yPos);
yPos -= 30;
if (yPos <= -150) {
sheetie.remove(this);
misses++;
}
}
}
void keyPressed() {
for (int i = 0; i < sheetie.size(); i++) {
note not = sheetie.get(i);
if (not.yPos >= 50 - cos((tick + not.randy * 2) / 5) * 25 && not.yPos <= 500 + cos((tick + not.randy * 2) / 5) * 25) {
if (str(key) == str(not.id)) {
score += int(1000 / (abs(not.yPos - 325) + 1));
sheetie.remove(i);
}
}
}
}
void mouseClicked() {
if (!started) {
sheetie.add(new note());
}
started = true;
}