-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflappyboi.pde
49 lines (41 loc) · 988 Bytes
/
flappyboi.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
PillarManager pillars;
Population BirdPop;
final int[] brainStruct = {4, 5, 2};
final int popsize = 100;
final int survivor = 10;
color yellow = color(255,200,0);
color green = color(100,200,0);
void setup()
{
randomSeed(0);
size(600,800);
BirdPop = new Population(popsize);
for(int i=0; i<BirdPop.pop.length; i++) BirdPop.pop[i] = new Bird(brainStruct);
pillars = new PillarManager();
}
void draw()
{
background(255);
pillars.move();
fill(yellow);
for(int i=0; i<BirdPop.pop.length; i++)
{
Bird flappyboi = (Bird)BirdPop.pop[i];
//Check collision with only the heading pillar
if (pillars.pillarList.peek().isSplatted(flappyboi))
{
flappyboi.alive = false;
}else flappyboi.score++;
flappyboi.fall();
flappyboi.Do();
flappyboi.display();
}
fill(green);
pillars.display();
if(BirdPop.isTimeToEvolve())
{
BirdPop.evolve(survivor);
background(255);
pillars = new PillarManager();
}
}