Skip to content

Commit 8103ca0

Browse files
committed
lots of updates to timings
1 parent 71a5664 commit 8103ca0

15 files changed

+149
-106
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@ ___
5353
#### Visual:
5454
- [ ] Finish all the details
5555
- [x] maybe smaller birds
56+
- [x] **Maybe shooting stars**
57+
- [x] Fix plane trails?
58+
- [ ] toggle borealis automatically
59+
- [x] Change chimney smoke color
5660

57-
- [ ] **Maybe shooting stars**
58-
59-
- [ ] Fix plane trails?
61+
- [ ] Fade outs:
62+
- [ ] Plane trails
63+
- [ ]
6064

61-
- [x] Change chimney smoke color
65+
- [ ] Repeats
66+
- [ ] Bird idle
6267

6368
#### End product
6469
- [ ] Tie everything together
@@ -79,9 +84,9 @@ ___
7984
- [ ]
8085

8186
- [ ] Night
82-
- [ ] Occasionally turn on borealis
87+
- [x] Occasionally turn on borealis
8388
- [ ] Better night airplanes
84-
- [ ] Loop night airplanes
89+
- [x] Loop night airplanes
8590

8691
### Ideas/Brainstorming
8792

effects/birdFlock.js

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,90 @@
11
var canvasBirdFlock= document.getElementById('canvasBirdFlock');
22
var ctxBirdFlock= canvasBirdFlock.getContext('2d')
3+
var canvasBirdFlockReversed= document.getElementById('canvasBirdFlock2');
4+
var ctxBirdFlockReversed= canvasBirdFlockReversed.getContext('2d')
35

46
canvasBirdFlock.width = 2000
57
canvasBirdFlock.height = 2000
68

9+
canvasBirdFlockReversed.width = 3000
10+
canvasBirdFlockReversed.height = 3000
11+
712
var birdFlock= new Image();
813
birdFlock.src = "images/birdflock test2.png";
914

10-
var birdFlockActive
15+
var birdFlockReversed= new Image();
16+
// birdFlockReversed.src = "images/birdflock reversed.png";
17+
birdFlockReversed.src = "images/birdflock reversed2.png";
18+
19+
var birdFlockActive = false
20+
var birdFlockActiveReversed = false
21+
// var birdFlockActiveReversed
22+
23+
var birdFlockReverseInterval
1124

1225
var colsTest = 10;
1326
var rowsTest = 1;
1427

28+
var colsReversed= 10;
29+
var rowsReversed= 1;
30+
1531
var totalFramesTest = 10;
1632
var currentFrameTest = 0;
1733
var framesDrawnTest = 0;
1834

35+
var totalFramesReversed= 10;
36+
var currentFrameReversed= 0;
37+
var framesDrawnReversed= 0;
38+
1939
var srcXTest = 0;
2040
var srcYTest = 0;
41+
var srcXReversed= 0;
42+
var srcYReversed= 0;
2143

2244
var xBirdTest
2345
var yBirdTest
46+
var xBirdReversed
47+
var yBirdReversed
48+
49+
// var birdSpeedTest
50+
var birdSpeedReversed
2451

2552
var spriteWidthTest = birdFlock.width/colsTest
2653
var spriteHeightTest = birdFlock.height/rowsTest
54+
var spriteWidthReversed= birdFlockReversed.width/colsReversed
55+
var spriteHeightReversed= birdFlockReversed.height/rowsReversed
2756

2857
xBirdTest = canvasBirdFlock.width - 30
2958
yBirdTest = canvasBirdFlock.height/4
3059

60+
xBirdReversed= - 120
61+
yBirdReversed= canvasBirdFlock.height/4.5
62+
3163
birdSpeedTest= -1.2;
64+
birdSpeedReversed= 1;
65+
// birdSpeedReversed= 4;
3266

3367
ctxBirdFlock.globalAlpha = 0.4;
68+
ctxBirdFlockReversed.globalAlpha = 0.3;
3469

3570

3671

3772
function toggleBirdFlock() {
3873
birdFlockActive = !birdFlockActive
74+
birdFlockActiveReversed = !birdFlockActiveReversed
75+
3976
if (birdFlockActive) {
4077
animateBirdFlock();
41-
console.log('test active')
4278
}
79+
80+
if (birdFlockActiveReversed) {
81+
setTimeout(function() {
82+
animateBirdFlockReverse();
83+
},5000)
84+
}
85+
4386
else {
44-
console.log('test off')
87+
clearInterval(birdFlockReverseInterval)
4588
}
4689
}
4790

@@ -56,16 +99,18 @@ function animateBirdFlock() {
5699

57100
xBirdTest += birdSpeedTest;
58101

59-
if (xBirdTest < -30) {
60-
// console.log('test');
61-
xBirdTest = canvasBirdFlock.width - 30
102+
if (xBirdTest < -60) {
103+
setTimeout(function() {
104+
xBirdTest = canvasBirdFlock.width + 120
105+
},5000)
62106
}
63107

64108
framesDrawnTest++;
65109
if (framesDrawnTest > 5) {
66110
currentFrameTest++;
67111
framesDrawnTest = 0;
68112
}
113+
69114
requestAnimationFrame(animateBirdFlock)
70115
}
71116
else {
@@ -74,3 +119,33 @@ function animateBirdFlock() {
74119
}
75120

76121

122+
function animateBirdFlockReverse() {
123+
// if (birdFlockActiveReversed) {
124+
if (birdFlockActiveReversed) {
125+
ctxBirdFlockReversed.clearRect(0,0,canvasBirdFlockReversed.width,canvasBirdFlockReversed.height)
126+
127+
currentFrameReversed= currentFrameReversed% totalFramesReversed;
128+
srcXReversed= currentFrameReversed* spriteWidthReversed;
129+
130+
ctxBirdFlockReversed.drawImage(birdFlockReversed, srcXReversed, srcYReversed, spriteWidthReversed, spriteHeightReversed, xBirdReversed, yBirdReversed, spriteWidthReversed, spriteHeightReversed)
131+
132+
xBirdReversed += birdSpeedReversed;
133+
134+
if (xBirdReversed > canvasBirdFlockReversed.width + 60) {
135+
setTimeout(function() {
136+
xBirdReversed = -120
137+
}, 8000)
138+
}
139+
140+
framesDrawnReversed++;
141+
if (framesDrawnReversed> 5) {
142+
currentFrameReversed++;
143+
framesDrawnReversed= 0;
144+
}
145+
146+
requestAnimationFrame(animateBirdFlockReverse)
147+
}
148+
else {
149+
ctxBirdFlockReversed.clearRect(0,0,canvasBirdFlockReversed.width,canvasBirdFlockReversed.height);
150+
}
151+
}

effects/borealis.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ function animateBorealis() {
4545
framesDrawnB = 0;
4646
}
4747

48-
if (borealisOpacity < 0.3) {
48+
if (borealisOpacity < 0.2) {
4949
ctxBorealis.globalAlpha = borealisOpacity
5050
// borealisOpacity += 0.0005;
51-
borealisOpacity += 0.0005;
51+
borealisOpacity += 0.0004;
5252
}
5353

5454
}
@@ -60,7 +60,7 @@ function animateBorealis() {
6060
if (borealisFadeOut) {
6161
if (borealisOpacity > 0) {
6262
ctxBorealis.globalAlpha = borealisOpacity;
63-
borealisOpacity += -0.005;
63+
borealisOpacity += -0.0005;
6464
}
6565
requestAnimationFrame(animateBorealis);
6666
}
@@ -72,27 +72,25 @@ function toggleBorealis() {
7272
borealisActive = !borealisActive;
7373
if (borealisActive) {
7474
borealisFadeOut= false;
75-
console.log('borealis on')
76-
animateBorealis();
77-
// canvasBorealis.width = 1000
78-
// canvasBorealis.height = 1000
79-
// ctxBorealis.drawImage(borealis,0,0,canvasBorealis.width, canvasBorealis.height)
80-
81-
// ctxBorealis.globalAlpha = 0.3
82-
// ctxBorealis.globalAlpha = 1
83-
// setTimeout(function(){
84-
// // ctxBorealis.filter = "blur(5px)"
85-
// ctxBorealis.globalAlpha = 0.3;
75+
setTimeout(function() {
76+
animateBorealis();
77+
setTimeout(function() {
78+
toggleBorealis();
79+
}, 20000)
80+
// }, 2000)
81+
},15000)
8682
// },1000)
8783

88-
8984
} else {
9085
borealisFadeOut= true;
91-
// console.log('borealis off')
86+
console.log('borealis off')
9287
setTimeout(function() {
9388
ctxBorealis.clearRect(0,0,canvasBorealis.width,canvasBorealis.height);
94-
console.log('test')
9589
borealisFadeOut = false;
96-
},3000)
90+
},9000)
91+
// if (borealisOpacity < 0.1) {
92+
// ctxBorealis.clearRect(0,0,canvasBorealis.width,canvasBorealis.height);
93+
// borealisFadeOut = false;
94+
// }
9795
}
9896
}

effects/buttons.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ $(document).on('click', 'button2', function() {
1212
});
1313

1414
var cloudyButton= document.createElement('buttonSound');
15-
// cloudyButton.innerHTML = "<i class='material-icons'>rainy</i>"
1615
cloudyButton.innerHTML = "<i class='material-icons'>filter_drama</i>"
1716
cloudyButton.onclick = function() {
1817
cloudImage(); toggleRain(); toggleClouds(); toggleTitleBool();
@@ -21,17 +20,17 @@ document.body.appendChild(cloudyButton);
2120

2221
var dayButton= document.createElement('buttonSound');
2322
dayButton.innerHTML = "<i class='material-icons'>sunny</i>"
24-
// dayButton.onclick= dayImage;
2523
dayButton.onclick= function() {
26-
dayImage(); toggleBird();
24+
dayImage();
25+
toggleBird();
26+
toggleBirdFlock();
27+
togglePlane();
2728
toggleTitleBool();
28-
// toggleTitle();//toggleCloudsDay();
29+
toggleCloudsDay();
2930
}
3031
document.body.appendChild(dayButton);
3132

3233
var halfNightButton= document.createElement('buttonSound');
33-
// halfNightButton.textContent = "🌆"
34-
// halfNightButton.onclick = halfNight;
3534
halfNightButton.innerHTML = "<i class='material-icons'>wb_twilight</i>"
3635
halfNightButton.onclick = function() {
3736
halfNight(); toggleTitleBool();
@@ -40,11 +39,9 @@ halfNightButton.onclick = function() {
4039
document.body.appendChild(halfNightButton);
4140

4241
var fullNightButton= document.createElement('buttonSound');
43-
// fullNightButton.textContent = "🌃"
44-
// fullNightButton.textContent = "🌌"
4542
fullNightButton.innerHTML = "<i class='material-icons'>nights_stay</i>"
4643
fullNightButton.onclick = function() {
47-
fullNight(); toggleStars(); toggleTitleBool(); toggleComet();
44+
fullNight(); toggleStars(); toggleTitleBool(); toggleComet(); toggleBorealis();
4845
}
4946
document.body.appendChild(fullNightButton);
5047

effects/nightPlane.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ canvasNightPlane.height = 1000;
3232
xNightPlane = canvasNightPlane.width;
3333
yNightPlane = canvasNightPlane.height/2;
3434

35-
ctxNightPlane.globalAlpha = 0.2
35+
ctxNightPlane.globalAlpha = 0.1
3636
ctxNightPlane.filter = "blur(5px)"
3737

3838
function toggleNightPlane() {

0 commit comments

Comments
 (0)