-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leave Kapcacher for later and add WeekMaster
- Loading branch information
Showing
10 changed files
with
196 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,7 @@ fn resolveHTMLBuilding(build) { | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script src="https://unpkg.com/kaplay/dist/kaboom.js"></script> | ||
<script src="https://unpkg.com/[email protected]/kapcache.js" type="module"></script> | ||
<title> | ||
OKFunk | ||
</title> | ||
|
@@ -191,8 +192,8 @@ fn resolveHTMLBuilding(build) { | |
|
||
</head> | ||
<body> | ||
<script async="async" type="module">{{ 0 }}</script> | ||
<script src="JS/exports.js" type="module"></script> | ||
<script>{{ 0 }}</script> | ||
</body> | ||
</html> | ||
' |> str.trim() |> fmt.format(combined) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
ml := import('ml') | ||
ml := import('ml') | ||
weekmaster := import('weekmaster') | ||
|
||
window.GAMEPARTS := { | ||
ml: ml | ||
weekmaster: weekmaster | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
{ MLtoSObj: MLtoSObj } := import('ml') | ||
|
||
fn weekByName(c) { | ||
'weekLevels/mlp/' << c | ||
} | ||
|
||
fn getWeeksXML() { | ||
// Weeks.xml isnb't a folder, but in there so this okay | ||
weekByName('weeks.xml') | ||
} | ||
|
||
fn getWeekAsset(weekName, c) { | ||
weekByName(weekName) << '/' << c | ||
} | ||
|
||
fn getWeekXML(weekName) { | ||
getWeekAsset(weekName, 'main.xml') | ||
} | ||
|
||
fn getWeekSong(weekName, c) { | ||
getWeekAsset(weekName, 'songs/') << c | ||
} | ||
|
||
fn getSongAsset(weekName, songName, c) { | ||
getWeekSong(weekName, songName) << '/' << c | ||
} | ||
|
||
fn getSongXML(weekName, c) { | ||
getSongAsset(weekName, c, 'song.xml') | ||
} | ||
|
||
fn getChartXML(weekName, c) { | ||
getSongAsset(weekName, c, 'chart.xml') | ||
} | ||
|
||
fn getWeekSprite(weekName, c) { | ||
getWeekAsset(weekName, 'sprites/') << c | ||
} | ||
|
||
fn fetchWeekXML(weekName) { | ||
weekPath := getWeekXML(weekName) | ||
fetch(weekPath) | ||
} | ||
|
||
fn handleMLFormat(r) MLtoSObj(r, 'text/xml') | ||
fn handleMLText(r) r.text() | ||
|
||
fn parseWeekXML(weekName) { | ||
resText := with fetchWeekXML(weekName). | ||
then() handleMLText | ||
|
||
with resText. | ||
then() handleMLFormat | ||
} | ||
|
||
fn propagateWeek(weekData) { | ||
newWeek := weekData |> Object() | ||
|
||
songs := Object.entries(newWeek.songs) | ||
|
||
root := '' | ||
promArr := [] | ||
fn pPush(i) promArr.push(i) | ||
|
||
fn handleUrl(k, n) { | ||
SONGROLL_DATA := with rolloutSongUrl(n). | ||
then() fn(d) newWeek.songs.(k) <- d | ||
|
||
pPush(SONGROLL_DATA) | ||
} | ||
|
||
with songs.forEach() fn(e, i) { | ||
[kName, assetUrl] := e | ||
|
||
if kName = 'root' { | ||
ASSET_URL := root + assetUrl | ||
|
||
true -> root <- assetUrl | ||
_ -> handleUrl(kName, ASSET_URL) | ||
} | ||
} | ||
|
||
with Promise.all(promArr).then() fn() newWeek | ||
} | ||
|
||
fn fetchSongXML(weekName, songName) { | ||
songPath := getSongXML(weekName, songName) | ||
fetch(songPath) | ||
} | ||
|
||
fn parseSongXML(weekName, songName) { | ||
resText := with fetchSongXML(weekName, songName). | ||
then() fn(r) handleMLText | ||
|
||
with resText. | ||
then() handleMLFormat | ||
} | ||
|
||
fn parseSongXURL(songUrl) { | ||
resText := with fetch(songUrl). | ||
then() handleMLText | ||
|
||
with resText. | ||
then() handleMLFormat | ||
} | ||
|
||
fn parseSongEntries(song, v, i) { | ||
[key, val] := v | ||
|
||
v | ||
} | ||
|
||
fn parseSongPreload(song, v, i) { | ||
[key, val] := v | ||
|
||
v | ||
} | ||
|
||
fn parseSongPlaybacks(song, v, i) { | ||
[key, val] := v | ||
|
||
v | ||
} | ||
|
||
fn propagateSong(songData) { | ||
newSong := songData |> Object() | ||
|
||
entries := Object.entries(songData.entry) | ||
preload := Object.entries(songData.preload) | ||
playbacks := Object.entries(songData.playbacks) | ||
|
||
root := '' | ||
promArr := [] | ||
fn pPush(i...) promArr.push(i...) | ||
|
||
fn passSong(cb) fn(args...) cb(newSong, args...) | ||
|
||
entries <- with entries.map() passSong(parseSongEntries) | ||
preload <- with preload.map() passSong(parseSongPreload) | ||
playbacks <- with playbacks.map() passSong(parseSongPlaybacks) | ||
|
||
pPush( | ||
entries... | ||
) | ||
|
||
pPush( | ||
preload... | ||
) | ||
|
||
pPush( | ||
playbacks... | ||
) | ||
|
||
with Promise.all(promArr).then() fn() newSong | ||
} | ||
|
||
fn rolloutSongUrl(songUrl) { | ||
data := parseSongXURL(songUrl) | ||
with data.then() propagateSong | ||
} | ||
|
||
fn rolloutWeek(weekName) { | ||
data := parseWeekXML(weekName) | ||
with data.then() propagateWeek | ||
} | ||
|
||
with rolloutWeek('EmptyWeek').then() console.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,4 +167,6 @@ with scene('gameSelect') fn { | |
with wait(0.2) weekCall | ||
} | ||
|
||
Transition(BLACK).fadeOut(0.2) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ json := import('json') | |
fmt := import('fmt') | ||
path := import('path') | ||
|
||
// https://unpkg.com/[email protected]/kapcache.js | ||
oaka := import('oaka') | ||
|
||
// --- | ||
|
@@ -14,7 +15,8 @@ h! := 500 | |
globalThis.k := kaboom({ | ||
width: 600 | ||
height: 500 | ||
scale: w! / h! | ||
scale: w! / h!, | ||
plugins: [KapCacher.CacherPlugin] | ||
}) | ||
|
||
vv := visualViewport | ||
|
@@ -53,8 +55,6 @@ addEventListener('scroll', updateCanvas) | |
addEventListener('orientationchange', updateCanvas) | ||
document.addEventListener('fullscreenchange', updateCanvas) | ||
|
||
|
||
|
||
// --- | ||
|
||
scenes := import('../scenes/main') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters