Skip to content
This repository was archived by the owner on Jul 5, 2022. It is now read-only.

Commit f13249f

Browse files
Add files via upload (#3583)
Co-authored-by: Kobe Liesenborgs <[email protected]>
1 parent dfb4a1d commit f13249f

File tree

4 files changed

+20134
-0
lines changed

4 files changed

+20134
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class Pie {
2+
PVector pos;
3+
float r;
4+
int digit;
5+
float ySpeed;
6+
float angle;
7+
Pie(float x, float y) {
8+
this.pos = new PVector(x, y);
9+
this.r = 32;
10+
this.digit = floor(random(10));
11+
this.ySpeed = 0;
12+
this.angle=random(TWO_PI);
13+
}
14+
15+
void show() {
16+
push();
17+
translate(this.pos.x,this.pos.y);
18+
rotate(this.angle);
19+
stroke(255);
20+
strokeWeight(2);
21+
fill(177,176,180,200);
22+
circle(0, 0, this.r*2);
23+
fill(0);
24+
float d = this.r*2;
25+
float a = TWO_PI/9;
26+
for (int i = 0; i<this.digit; i++) {
27+
fill(255, 0, 255);
28+
stroke(255);
29+
arc(0, 0, d, d, a*i, (1+i)*a, PIE);
30+
}
31+
pop();
32+
//textSize(32);
33+
//textAlign(CENTER,CENTER);
34+
//text(this.digit,this.pos.x,this.pos.y-(this.r/2));
35+
}
36+
void update() {
37+
this.pos.y = this.pos.y + this.ySpeed;
38+
this.ySpeed = this.ySpeed + 0.05;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
ArrayList<Pie> pies = new ArrayList<>();
2+
Plate plate;
3+
String digits;
4+
String pi[];
5+
int piCounter = 0;
6+
Boolean gameOver = false;
7+
String piShow;
8+
int lineCounter = 0;
9+
void setup() {
10+
size(800, 600);
11+
pi = loadStrings("one-million.txt");
12+
digits = "3.";
13+
plate = new Plate(width/2, 50);
14+
piShow = pi[lineCounter].substring(0, 2);
15+
}
16+
void draw() {
17+
if (gameOver) {
18+
background(255, 0, 0);
19+
fill(255);
20+
textAlign(CENTER, CENTER);
21+
text("Gane Over. \nGo and Enjoy Some Pie! ", width/2, height/2);
22+
return;
23+
}
24+
background(0);
25+
fill(255);
26+
textSize(48);
27+
text(piShow.charAt(1), width-32, 50);
28+
fill(0, 255, 0);
29+
text(piShow.charAt(0), width-64, 50);
30+
if (random(1)<0.05) {
31+
pies.add(new Pie(random(width), random(-100, -20)));
32+
}
33+
for (Pie pie : pies) {
34+
pie.show();
35+
pie.update();
36+
}
37+
for (int i = pies.size()-1; i>=0; i--) {
38+
if (plate.catches(pies.get(i))) {
39+
int digit = pies.get(i).digit;
40+
//digits += pies.get(i).digit;
41+
//String test = pi.;
42+
int correctDigit = Character.getNumericValue((piShow.charAt(0)));
43+
if (correctDigit == digit) {
44+
digits += digit;
45+
piCounter++;
46+
if(piCounter == 50){
47+
lineCounter++;
48+
piCounter = 0;
49+
}
50+
piShow = pi[lineCounter].substring(piCounter, piCounter +2);
51+
pies.remove(i);
52+
} else {
53+
gameOver = true;
54+
}
55+
} else if (pies.get(i).pos.y > height-200 +pies.get(i).r) {
56+
pies.remove(i);
57+
}
58+
}
59+
plate.show();
60+
plate.update(mouseX);
61+
println(pies.size());
62+
fill(255);
63+
rect(width/2, height, width, 400);
64+
textSize(32);
65+
textAlign(CENTER);
66+
fill(0);
67+
text("Digits of pie", width/2, 425);
68+
text(digits, width/2, 450);
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Plate {
2+
PVector pos;
3+
float h;
4+
float w;
5+
Plate(float x, float w) {
6+
this.pos = new PVector(x, height-200 -this.h);
7+
this.w = w;
8+
this.h = 10;
9+
}
10+
void show() {
11+
fill(255);
12+
rectMode(CENTER);
13+
rect(this.pos.x, this.pos.y, this.w, this.h);
14+
}
15+
void update(float x) {
16+
this.pos.x = x;
17+
}
18+
Boolean catches(Pie pie) {
19+
if (pie.pos.y +pie.r >= this.pos.y && this.pos.y >0&& pie.pos.x > this.pos.x-this.w/2 && pie.pos.x < this.pos.x + this.w/2) {
20+
return true;
21+
} else {
22+
return false;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)