-
Notifications
You must be signed in to change notification settings - Fork 0
/
albedo.html
8952 lines (8039 loc) · 179 KB
/
albedo.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<html>
<!-- HEADER -->
<head>
<meta charset="UTF-8">
<title>Albedo</title>
<script type="text/bitsyGameData" id="exportedGameData">
Albedo
# BITSY VERSION 6.4
! ROOM_FORMAT 1
PAL 0
76,86,106
94,129,172
129,161,193
216,222,233
236,239,244
191,97,106
180,142,173
143,188,187
ROOM 0
b,b,b,b,b,b,d,c,d,0,d,d,d,0,c,c
b,b,b,b,d,c,c,c,c,c,c,0,d,d,d,d
b,b,b,c,0,0,0,0,0,c,0,d,0,0,d,0
b,b,b,c,0,i,c,0,c,0,c,0,c,d,c,d
b,b,b,c,c,c,0,c,0,c,0,0,c,c,d,c
b,b,c,c,0,c,0,c,c,c,0,c,c,c,0,d
b,b,d,c,0,0,0,0,c,0,0,0,c,0,d,d
b,b,b,c,0,c,0,0,d,c,0,c,0,0,c,d
b,b,b,b,c,0,c,0,c,c,c,c,0,0,c,0
b,b,b,b,c,0,c,c,0,c,0,c,0,0,0,c
b,b,b,b,c,c,0,c,0,c,0,0,0,c,0,d
b,b,b,b,c,0,0,d,c,c,c,c,c,0,d,c
b,b,d,c,0,0,c,c,0,c,c,d,c,d,0,c
b,b,b,c,0,0,0,c,0,0,c,0,0,c,d,c
b,b,b,d,0,c,0,c,0,0,0,0,d,0,d,c
b,b,b,b,b,b,c,d,c,0,d,c,c,d,0,c
NAME Landing
EXT 9,0 1 9,15 FX slide_u
EXT 5,3 3 5,7 FX tunnel
PAL 0
ROOM 1
b,b,b,b,b,b,b,c,e,c,d,e,c,c,d,e
b,b,b,b,d,c,0,c,0,e,e,c,e,d,e,d
b,b,d,c,0,0,0,0,0,c,0,e,c,e,c,e
b,b,d,b,0,c,0,c,c,c,e,c,0,c,d,e
b,b,b,b,b,b,d,c,0,0,0,0,e,c,d,e
b,b,b,b,b,b,b,c,0,0,d,0,e,c,c,f
b,b,b,b,b,b,d,0,0,0,c,c,d,e,c,e
b,b,c,d,b,b,b,c,0,0,0,c,c,d,0,e
b,c,c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
ITM 2 14,10
EXT 1,10 3 6,5 FX fade_w
PAL 0
ROOM 5
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,j,j,j,j,j,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,r,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,0,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,0,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,0,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,0,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,0,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,0,j,0,0,0,0,0
0,0,0,0,0,j,0,0,0,0,j,0,0,0,0,0
0,0,0,0,0,0,j,0,0,j,0,0,0,0,0,0
0,0,0,0,0,0,0,j,j,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
NAME Cargo Hold
EXT 9,3 3 9,5 FX tunnel
PAL 0
TIL b
00000000
00000000
00000000
00110010
01001100
00000000
00000000
00000000
>
00000000
00000000
00000000
01001100
00110010
00000000
00000000
00000000
NAME water
WAL true
TIL c
00000000
00000000
00000000
00000000
00011000
00100100
00000000
00000000
NAME snow
COL 3
TIL d
00000000
00000000
00011000
00100100
01011110
01101010
00000000
00000000
NAME mound
WAL true
COL 4
TIL e
00011000
00100100
00101010
01011110
01111111
11111111
11111111
00000000
NAME mountain
WAL true
COL 4
TIL f
00011000
00100100
00101010
01011110
01100111
11000011
11000011
00000000
NAME cave
COL 4
TIL g
00000000
00111100
01000110
01001010
01010110
01101010
00111100
00000000
NAME cave wall
WAL true
COL 3
TIL i
00000001
11111111
01111111
00000000
00100100
00100010
01110111
00000000
NAME ship4
COL 2
TIL j
00000000
01111110
01000110
01001110
01011110
01111110
01111110
00000000
NAME metal wall
WAL true
COL 3
TIL k
00000000
01111110
01000010
01000010
01010010
01000010
01000010
00000000
NAME metal door
COL 2
TIL l
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
NAME invisible wall
WAL true
TIL m
00000000
01111111
01001010
01001101
01001010
01001101
01111111
00100000
NAME bed1
COL 5
TIL n
00000000
11111110
10101010
01010110
10101010
01010110
11111110
00000100
NAME bed2
COL 5
TIL o
00000000
01111110
00000100
00001000
00010000
00100000
01111110
00000000
NAME z
COL 4
TIL p
00000000
11111111
00000000
01010110
00000110
01010110
00000000
00000000
NAME panel
WAL true
COL 2
TIL q
00000000
00100100
00111100
00100100
01111110
10100101
01111110
00000000
NAME down
COL 2
TIL r
00100100
00111100
00100100
00111100
00100100
00111100
00100100
00000000
NAME up
COL 2
SPR A
00011000
00110100
00100100
01111110
11111111
10111101
00100100
01100110
POS 3 7,10
SPR a
11000000
11111111
01111110
00000000
00100100
01000100
11101110
00000000
NAME ship3
DLG SPR_0
POS 0 4,3
SPR c
00000000
00000000
00000000
00000000
00000000
11111000
10100100
11111110
NAME ship2
DLG SPR_2
POS 0 5,2
SPR d
00000000
00000000
00000000
00000000
01100000
01010001
01101010
01111111
NAME ship1
DLG SPR_3
POS 0 4,2
SPR e
01010010
10001001
10010001
11111111
11110011
11111011
11110001
11111111
NAME towerb1
DLG SPR_4
POS 1 8,6
SPR f
00000000
00011000
00101100
00110100
00011000
00101100
00110100
01001010
>
00000000
00011000
00110100
00101100
00011000
00101100
00110100
01001010
NAME towert1
POS 1 8,5
SPR g
00000000
01110000
01010000
01010000
01111110
00111100
01111110
00000000
NAME toilet
DLG SPR_1
POS 3 6,3
COL 4
SPR j
00000000
11111111
00000000
01011010
01111110
01000010
00000000
00000000
NAME shipcontrols
DLG SPR_7
POS 3 7,11
SPR k
01111110
01000010
01111110
01000010
01111110
01000010
01111110
00000000
NAME faunashelf
DLG SPR_8
POS 5 6,5
COL 5
SPR l
00000000
00011110
00111010
00100010
00001010
00010010
01111110
00000000
>
00000000
00011110
00111010
00010010
00100010
00001010
01111110
00000000
NAME shower
DLG SPR_5
POS 3 9,3
COL 4
SPR m
01111110
01000010
01111110
01000010
01111110
01000010
01111110
00000000
NAME florashelf
DLG SPR_6
POS 5 6,6
COL 7
ITM 0
00000000
00000000
00011000
00100100
00101100
00111100
00011000
00000000
>
00000000
00011000
00100100
00101100
00111100
00011000
00000000
00000000
NAME crystal
DLG ITM_0
COL 6
ITM 1
00000000
00111100
01100110
01000010
01100110
01111110
00111100
00000000
NAME nest
DLG ITM_1
COL 5
ITM 2
00000000
01111110
00000100
00001000
00010000
00100000
01111110
00000000
NAME dreamz
DLG ITM_2
DLG SPR_0
"""
Your scout ship stands in the snow, ready to be loaded with the scientific samples you are to collect during your stay.
PILIUN CRYSTAL SAMPLES:
({say crystal}/100)
WILDLIFE GENETIC SAMPLES:
({say genetic}/25)
ALBEDO MEASUREMENT DATA:
({say albedo}/10)
"""
DLG SPR_2
The heavy snowfall is already beginning to pile on your ship.
DLG SPR_3
You watch the snowflakes fall down on your ship, slowly building in size.
DLG SPR_4
"""
RADAR TOWER 01
Operated by Curiosity Base.
LIST OF NEARBY CORDINATES:
Current Location: (X0 Y1)
Curiosity Base: (X? Y?)
"""
DLG ITM_0
{crystal = crystal + 1}You extract a sample of Piliun crystal. ({say crystal}/100)
DLG SPR_1
"""
You use the toilet. The automated system recycles your excrements into fertilizer for the ship's plant habitat.
You feel much better now!
"""
DLG ITM_1
{genetic =+ 1}You found a nest belonging to one of Adlivun's creatures! You scan the nest and find genetic samples to collect. ({say genetic}/25)
DLG SPR_7
You can't leave until you've checked on the researchers and collected all of the requested scientific samples and data!
DLG SPR_8
"""
{cycle
- This bookshelf contains a book about the creatures of Adlivun.
(Interact again to read)
- A GUIDE TO THE FAUNA OF ADLIVUN
by Emma Teague
- Chapter 1: The Ukpik.
The Ukpik is a heavy-set bird, slightly larger than a condor back on Earth, with facial features similar to an owl. The bird has an arsenal of methods it uses to stay alive in the harsh frost of Adlivun, ranging from it's incredibly fluffy feathers, which are used to trap insulating pockets of air around it's body. One of it's best tactics is how it flies the body of it's downed prey back to it's cave nest, where it's meat is quickly packed into the snow to be preserved for when the bird needs a meal. Yummy! It's most notable feature, however, is that it can digest Piliun crystals. After swallowing one, it's digestive system slowly breaks the crystal down into its natural components, giving more energy for the bird. For this reason, the Ukpiks stock their caves with Piliun crystals to digest when they are ready for it!
- Chapter 2: The Qalupalik.
The secretive Qalupalik is a water-dwelling, humanoid, extraterrestrial being found on Adlivun. It has been confirmed to be sentient. The rest of the creature's species has gone extinct, likely due to it's relatively inefficient method of catching prey on the shore from the water, as well as its massive body, which requires a large quantity of nutrients to support itself. However, because of it's high swimming speeds, as well as it's powerful hunting capabilities, the Qalupalik is a powerful threat to any living entity that dares to walk near certain shores of Adlivun. All attempts to capture it have failed as of yet.
}
"""
DLG SPR_5
"""
You use the ship's shower. The dirt on your body washes off with the droplets and is then taken to be recycled into fuel for the ship.
Refreshing!
"""
DLG ITM_2
"""
{shuffle
- You dream of a cave, nestled in snow-covered mountains, where a large, mysterious bird sleeps in it's nest.
- You dream of a horrifying humanoid entity with rough green skin, a woolly jacket and long black hair rising up out of the frigid waters, poised to strike.
- You dream about you dreaming about you dreaming about you d...
- You dream of making your way through a valley, completely buried by the frigid snow, trying not to sink in.
- You dream of a wrecked building, with frozen bodies littered across the snow.
}
"""
DLG SPR_6
"""
{cycle
- This bookshelf contains books about the plant life of Adlivun.
(Interact again to read)
- A GUIDE TO THE FLORA OF ADLIVUN
by Liam Aijatkuk
- Chapter 1: The Piliun crystal.
}
"""
VAR crystal
0
VAR genetic
0
VAR albedo
0
</script>
<style>
html {
margin:0px;
padding:0px;
}
body {
margin:0px;
padding:0px;
overflow:hidden;
background:#ffffff;
}
#game {
background:black;
width:100vw;
max-width:100vh;
margin:auto;
display:block;
}
</style>
<!-- SCRIPTS -->
<script>
function startExportedGame() {
attachCanvas( document.getElementById("game") );
load_game( document.getElementById("exportedGameData").text.slice(1) );
}
</script>
<script>
//hex-to-rgb method borrowed from stack overflow
function hexToRgb(hex) {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function hslToHex(h,s,l) {
var rgbArr = hslToRgb(h,s,l);
return rgbToHex( Math.floor(rgbArr[0]), Math.floor(rgbArr[1]), Math.floor(rgbArr[2]) );
}
function hexToHsl(hex) {
var rgb = hexToRgb(hex);
return rgbToHsl(rgb.r, rgb.g, rgb.b);
}
// really just a vector distance
function colorDistance(a1,b1,c1,a2,b2,c2) {
return Math.sqrt( Math.pow(a1 - a2, 2) + Math.pow(b1 - b2, 2) + Math.pow(c1 - c2, 2) );
}
function hexColorDistance(hex1,hex2) {
var color1 = hexToRgb(hex1);
var color2 = hexToRgb(hex2);
return rgbColorDistance(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b);
}
// source : http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
/* accepts parameters
* h Object = {h:x, s:y, v:z}
* OR
* h, s, v
*/
function HSVtoRGB(h, s, v) {
var r, g, b, i, f, p, q, t;
if (arguments.length === 1) {
s = h.s, v = h.v, h = h.h;
}
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0: r = v, g = t, b = p; break;
case 1: r = q, g = v, b = p; break;
case 2: r = p, g = v, b = t; break;
case 3: r = p, g = q, b = v; break;
case 4: r = t, g = p, b = v; break;
case 5: r = v, g = p, b = q; break;
}
return {
r: Math.round(r * 255),
g: Math.round(g * 255),
b: Math.round(b * 255)
};
}
/* accepts parameters
* r Object = {r:x, g:y, b:z}
* OR
* r, g, b
*/
function RGBtoHSV(r, g, b) {
if (arguments.length === 1) {
g = r.g, b = r.b, r = r.r;
}
var max = Math.max(r, g, b), min = Math.min(r, g, b),
d = max - min,
h,
s = (max === 0 ? 0 : d / max),
v = max / 255;
switch (max) {
case min: h = 0; break;
case r: h = (g - b) + d * (g < b ? 6: 0); h /= 6 * d; break;
case g: h = (b - r) + d * 2; h /= 6 * d; break;
case b: h = (r - g) + d * 4; h /= 6 * d; break;
}
return {
h: h,
s: s,
v: v
};
}
// source : https://gist.github.com/mjackson/5311256
/**
* Converts an HSL color value to RGB. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes h, s, and l are contained in the set [0, 1] and
* returns r, g, and b in the set [0, 255].
*
* @param Number h The hue
* @param Number s The saturation
* @param Number l The lightness
* @return Array The RGB representation
*/
function hslToRgb(h, s, l) {
var r, g, b;
if (s == 0) {
r = g = b = l; // achromatic
} else {
function hue2rgb(p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1/6) return p + (q - p) * 6 * t;
if (t < 1/2) return q;
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
return p;
}
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1/3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1/3);
}
return [ r * 255, g * 255, b * 255 ];
}
/**
* From: http://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion
*
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param {number} r The red color value
* @param {number} g The green color value
* @param {number} b The blue color value
* @return {Array} The HSL representation
*/
function rgbToHsl(r, g, b){
r /= 255, g /= 255, b /= 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if(max == min){
h = s = 0; // achromatic
}else{
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch(max){
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
case g: h = (b - r) / d + 2; break;
case b: h = (r - g) / d + 4; break;
}
h /= 6;
}
return [h, s, l];
}
</script>
<script>
var TransitionManager = function() {
var transitionStart = null;
var transitionEnd = null;
var effectImage = null;
var isTransitioning = false;
var transitionTime = 0; // milliseconds
var frameRate = 8; // cap the FPS
var prevStep = -1; // used to avoid running post-process effect constantly
this.BeginTransition = function(startRoom,startX,startY,endRoom,endX,endY,effectName) {
// console.log("--- START ROOM TRANSITION ---");
curEffect = effectName;
var tmpRoom = player().room;
var tmpX = player().x;
var tmpY = player().y;
if (transitionEffects[curEffect].showPlayerStart) {
player().room = startRoom;
player().x = startX;
player().y = startY;
}
else {
player().room = "_transition_none"; // kind of hacky!!
}
drawRoom(room[startRoom]);
var startPalette = getPal( room[startRoom].pal );
var startImage = new PostProcessImage( ctx.getImageData(0,0,canvas.width,canvas.height) ); // TODO : don't use global ctx?
transitionStart = new TransitionInfo(startImage, startPalette, startX, startY);
if (transitionEffects[curEffect].showPlayerEnd) {
player().room = endRoom;
player().x = endX;
player().y = endY;
}
else {
player().room = "_transition_none";
}
drawRoom(room[endRoom]);
var endPalette = getPal( room[endRoom].pal );
var endImage = new PostProcessImage( ctx.getImageData(0,0,canvas.width,canvas.height) );
transitionEnd = new TransitionInfo(endImage, endPalette, endX, endY);
effectImage = new PostProcessImage( ctx.createImageData(canvas.width,canvas.height) );
isTransitioning = true;
transitionTime = 0;
prevStep = -1;
player().room = tmpRoom;
player().x = tmpX;
player().y = tmpY;
}
this.UpdateTransition = function(dt) {
if (!isTransitioning) {
return;
}
transitionTime += dt;
var transitionDelta = transitionTime / transitionEffects[curEffect].duration;
var maxStep = Math.floor(frameRate * (transitionEffects[curEffect].duration / 1000));
var step = Math.floor(transitionDelta * maxStep);
if (step != prevStep) {
// console.log("step! " + step + " " + transitionDelta);
for (var y = 0; y < effectImage.Height; y++) {
for (var x = 0; x < effectImage.Width; x++) {
var color = transitionEffects[curEffect].pixelEffectFunc(transitionStart,transitionEnd,x,y,(step / maxStep));
effectImage.SetPixel(x,y,color);
}
}
}
prevStep = step;
ctx.putImageData(effectImage.GetData(), 0, 0);
if (transitionTime >= transitionEffects[curEffect].duration) {
isTransitioning = false;
transitionTime = 0;
transitionStart = null;
transitionEnd = null;
effectImage = null;
prevStep = -1;
}
}
this.IsTransitionActive = function() {
return isTransitioning;
}
var transitionEffects = {};
var curEffect = "none";
this.RegisterTransitionEffect = function(name, effect) {
transitionEffects[name] = effect;
}
this.RegisterTransitionEffect("none", {
showPlayerStart : false,
showPlayerEnd : false,
pixelEffectFunc : function() {},
});
this.RegisterTransitionEffect("fade_w", { // TODO : have it linger on full white briefly?
showPlayerStart : false,
showPlayerEnd : true,
duration : 750,
pixelEffectFunc : function(start,end,pixelX,pixelY,delta) {