PageSourceSearch

https://2020game.io/js/timeline.js

js 2020game.io collected 2026-09-25 14:14:06 UTC 4,464 bytes, 137 lines download raw bytes

1import Properties from './properties.js'
2import Level0 from './levels/level0.js'
3import Level1 from './levels/level1.js'
4import Level2 from './levels/level2.js'
5import Level3 from './levels/level3.js'
6import Level4 from './levels/level4.js'
7import Level5 from './levels/level5.js'
8import Level6 from './levels/level6.js'
9import Level7 from './levels/level7.js'
10import Outro from './levels/outro.js'
11
12const HANDLERS = {
13    // Level 0
14    '0-load': Level0.preloadLevel,
15    '0-checkpoint0': Level0.checkpoint0,
16    '0-title': Level0.showTitle,
17    // Level 1
18    '1-load': Level1.preloadLevel,
19    '1-checkpoint1': Level1.checkpoint1,
20    '1-title': Level1.showTitle,
21    '1-checkpoint2': Level1.checkpoint2,
22    '1-wildfires': Level1.startWildfires,
23    '1-tree-falls': Level1.treeFalls,
24    '1-koala-jumps': Level1.koalaJumps,
25    '1-clear': Level1.clear,
26    // Level 2
27    '2-load': Level2.preloadLevel,
28    '2-checkpoint3': Level2.checkpoint3,
29    '2-bat': Level2.addFlyingBat,
30    '2-quarantine-ready': Level2.showQuarantineTitle,
31    '2-clear': Level2.clear,
32    // Level 3
33    '3-load': Level3.preloadLevel,
34    '3-checkpoint4': Level3.checkpoint4,
35    '3-title': Level3.showTitle,
36    '3-checkpoint5': Level3.checkpoint5,
37    '3-google': Level3.stockGoogle,
38    '3-amazon': Level3.stockAmazon,
39    '3-microsoft': Level3.stockMicrosoft,
40    '3-facebook': Level3.stockFacebook,
41    '3-apple': Level3.stockApple,
42    '3-checkpoint6': Level3.checkpoint6,
43    '3-quarantine': Level3.startQuarantine,
44    '3-resume-music': Level3.resumeMusic,
45    // Level 4
46    '4-load': Level4.preloadLevel,
47    '4-checkpoint7': Level4.checkpoint7,
48    '4-title': Level4.showTitle,
49    '4-smog': Level4.fadeOutSmog,
50    '4-dolphins': Level4.addDolphins,
51    '4-checkpoint8': Level4.checkpoint8,
52    '4-checkpoint9': Level4.checkpoint9,
53    '4-clear': Level4.clear,
54    // Level 5
55    '5-load': Level5.preloadLevel,
56    '5-checkpoint10': Level5.checkpoint10,
57    '5-checkpoint11': Level5.checkpoint11,
58    '5-5G-start': Level5.startCoronaGeneration,
59    '5-5G-stop': Level5.stopCoronaGeneration,
60    '5-checkpoint12': Level5.checkpoint12,
61    '5-clear': Level5.clear,
62    // Level 6
63    '6-load': Level6.preloadLevel,
64    '6-checkpoint13': Level6.checkpoint13,
65    '6-floods': Level6.floodsTitle,
66    '6-checkpoint14': Level6.checkpoint14,
67    '6-race': Level6.raceTitle,
68    '6-race1': () => Level6.startRace(),
69    '6-race2': () => Level6.bidenLeads(),
70    '6-race3': () => Level6.trumpLeads(),
71    '6-race4': () => Level6.bidenNitro(),
72    '6-clear': Level6.clear,
73    // Level 7
74    '7-load': Level7.preloadLevel,
75    '7-checkpoint15': Level7.checkpoint15,
76    '7-title': Level7.showTitle,
77    '7-attack-start': Level7.startCorona,
78    '7-attack-stop': Level7.removeCorona,
79    '7-reset': Level7.removeSyringe,
80    '7-game-win': Level7.gameWin,
81    '7-clear': Level7.clear,
82    // Outro
83    'o-load': Outro.preloadLevel
84}
85
86let current = 0
87
88export function moveToEvent(eventName) {
89    // Shift
90    shiftTimeline(eventName)
91    // Get event
92    let event = Properties.timelineEvents[current]
93    // Get current level number
94    let level = parseInt(event.name[0])
95    // Check and load previous level
96    if (level > 0) { handleEvent(`${level - 1}-load`) }
97    // Then load current level
98    handleEvent(`${level}-load`)
99    // Move camera and player
100    if (level === 0) {
101        // Place in the beginning for Level 0
102        let offsetX = 250
103        Properties.camera.scrollX = event.x
104        Properties.player.x = event.x + offsetX
105    } else {
106        // Place in center for other levels
107        Properties.camera.scrollX = event.x - Properties.sceneSize.width / 2
108        Properties.player.x = event.x
109    }
110}
111
112export function shiftTimeline(eventName) {
113    // Seek for the event
114    let index = Properties.timelineEvents.findIndex(event => event.name === eventName)
115    // Set current from index (to 0 if not found)
116    current = index !== -1 ? index : 0
117}
118
119export function checkTimeline() {
120    if (current >= Properties.timelineEvents.length) { return }
121
122    if (Properties.timelineEvents[current].x <= Properties.player.x) {
123        let currentEvent = Properties.timelineEvents[current].name
124        // Handle
125        handleEvent(currentEvent)
126        // Move to next event
127        current++
128    }
129}
130
131function handleEvent(event) {
132    if (event in HANDLERS) {
133        HANDLERS[event]()
134    } else {
135        console.log(`${event} event handler not found`)
136    }
137}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.