-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
52 lines (51 loc) · 1.05 KB
/
sketch.js
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
let dist;
let level;
let scoreCounter = 0;
let canvasW;
let canvasH;
let pipeImg;
let pipeImgRev;
let bg;
let flag = false;
let generationLimit = 10;
function setup() {
canvasW = windowWidth;
canvasH = windowHeight - 50;
createCanvas(canvasW, canvasH);
frameRate(60);
setupImages();
dist = 0;
level = new Level();
bg = new Background();
tempml = new MachineLearning(4, 1, [8, 8, 4, 2]);
strokeWeight(1);
//level.draw();
initBirds();
document.getElementById("score").innerHTML = score;
document.getElementById("generation").innerHTML = generation;
//draw();
//noLoop();
//while (true) {
// draw();
//}
}
function draw() {
background(174, 106, 138);
if (aliveBirds == 0 && birdsInitialised == true) {
nextGenerationBirds();
}
if (score > generationLimit) {
generationLimit += 10;
nextGenerationBirds();
}
fill(255);
bg.draw();
level.draw();
fill(100);
if (birdsInitialised) {
showBirds();
}
flag = false;
document.getElementById("alive").innerHTML = aliveBirds;
//image(pipeImgRev, 0, 0);
}