Skip to content

Commit

Permalink
Migrate to Kaplay!
Browse files Browse the repository at this point in the history
  • Loading branch information
SpcFORK committed May 27, 2024
1 parent b9797f5 commit d8655c4
Show file tree
Hide file tree
Showing 23 changed files with 648 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .replit
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ requiredFiles = [".replit", "replit.nix", ".config", ".config/bin/oak"]
[languages]

[languages.javascript]
pattern = "**/{*.js,*.jsx,*.ts,*.tsx,*.oak}"
pattern = "**/{*.js,*.jsx,*.ts,*.tsx}"
[languages.javascript.languageServer]
start = "typescript-language-server --stdio"

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const kaboom = require("kaboom");
const kaboom = require("kaplay");
let mod = require("./build/entry.js");

console.log(mod || "No Exports found.");
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"@types/node": "^18.0.6",
"kaboom": "^3000.1.17",
"kaplay": "^3000.1.17",
"node-fetch": "^3.2.6",
"ts-loader": "^9.5.1",
"tsc": "^2.0.4",
Expand Down
5 changes: 4 additions & 1 deletion scenes/init/core.oak
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ str := import('str')
json := import('json')
rng := import('random')


{
Transition: Transition
PixelTransition: PixelTransition
} := import('../blocks/Transition')


{ newCut: newCut } := import('../ware/cutscene')
{ shakey: shakey } := import('../blocks/shakey')


// Check if we can play Sounds
FirstInput? := false
IS_IFRAME := (window.location != window.parent.location)
Expand Down Expand Up @@ -100,7 +103,7 @@ fn enterNextH(sce, key?, cb) {
nextPress.cancel()

Transition(BLACK).fadeIn(0.2)
with wait(0.2) fn {
with wait(0.5) fn {
go(sce)
if cb != ? -> cb()
}
Expand Down
1 change: 1 addition & 0 deletions scenes/init/gameParts/all.oak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ml := import('ml')
29 changes: 29 additions & 0 deletions scenes/init/gameParts/ml.oak
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// © SpcFORK 2024

std := import('std')

// ML to Serialized Object or String.
fn MLtoSObj(htmlStr, type) {
parser := with new() DOMParser
xmlDoc := parser.parseFromString(htmlStr, type)

fn parseNode(node) {
result := {}

fn handleNoChildren if node.attributes.length > 0 {
with std.each(node.attributes) fn(ii) if ii != ? -> result.(ii.name) <- ii.value

true -> result.'__text' <- node.textContent
_ -> result <- node.textContent |> std.default('')
}

if node.children.length = ? | node.children.length <= 0 {
true -> handleNoChildren()
_ -> with std.each(node.children) fn(ii) result.(ii.localName) <- parseNode(ii)
}

result
}

parseNode(xmlDoc.documentElement)
}
1 change: 1 addition & 0 deletions scenes/init/main.oak
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ GLOBAL_LOADED_FILES := window.GLOBAL_LOADED_FILES := {
PRELOAD := import('menu/preload')
loadingScreen := import('loadingScreen')
actualGame := import('actualGame')
gameParts := import('gameParts/all')

{
gwibble: gwibble
Expand Down
8 changes: 7 additions & 1 deletion scenes/init/menu/optionScenes/audio.oak
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ with scene('op_audio') fn {
optionCall := sl.getItem()
optionCall()
}
}
}


with scene('op_audio_all') fn {}
with scene('op_audio_msc') fn {}
with scene('op_audio_vcl') fn {}
with scene('op_audio_snd') fn {}
6 changes: 5 additions & 1 deletion scenes/init/menu/optionScenes/graphics.oak
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ with scene('op_graphics') fn {
optionCall := sl.getItem()
optionCall()
}
}
}

with scene('op_graphics_gamma') fn {}
with scene('op_graphics_zoom') fn {}
with scene('op_graphics_shaders') fn {}
7 changes: 6 additions & 1 deletion scenes/init/menu/optionScenes/key.oak
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,9 @@ with scene('op_kb') fn {
optionCall := sl.getItem()
optionCall()
}
}
}


with scene('op_kb_g') fn {}
with scene('op_kb_m') fn {}
with scene('op_kb_c') fn {}
6 changes: 3 additions & 3 deletions scenes/init/menu/options.oak
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ with scene('options') fn {

// ---

songs := {
options := {
'Graphics': fn() go('op_graphics')
'Audio': fn() go('op_audio')
'Keybinds': fn() go('op_kb')
Expand All @@ -60,9 +60,9 @@ with scene('options') fn {

// ---

songKeys := keys(songs)
songKeys := keys(options)

sl := ScrollableList(songs, ?, ?, 50)
sl := ScrollableList(options, ?, ?, 50)

fn moveUp {
with sl.moveForward() fn() playTickSound()
Expand Down
59 changes: 36 additions & 23 deletions scenes/init/menu/storyMode.oak
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,44 @@ rng := import('random')

{
week1: week1
week2: week2
week3: week3
week4: week4
week5: week5
week6: week6
week7: week7
week8: week8
} := import('weekLoading/all')


// ---
// @Storymode
// Expect to come here a lot.

StoryWeeks := {
'Week 1': fn() console.log('week')
'Week 2': fn() console.log('week')
'Week 3': fn() console.log('week')
'Week 4': fn() console.log('week')
'Week 5': fn() console.log('week')
'Week 6': fn() console.log('week')
'Week 7': fn() console.log('week')
'Week 1': week1.load
'Week 2': week2.load
'Week 3': week3.load
'Week 4': week4.load
'Week 5': week5.load
'Week 6': week6.load
'Week 7': week7.load
'Week 8': week8.load
}

WeekNames := []
// num + 1 weeks then next stop
with std.loop(StoryWeeks |> len() + 1) fn(ic) {
WeekNames << ('Week ' + s(ic))
}

// @Modder exposed
window.StoryWeeks := {
get: fn() StoryWeeks
set: fn(k, x) StoryWeeks.(k) <- x
}

// ---

with scene('storyMode') fn {

enterNextH('gameSelect', 'escape')
Expand Down Expand Up @@ -111,15 +132,7 @@ with scene('storyMode') fn {

// ---

WeekNames := []
// 8 Being 7 weeks then next stop
with std.loop(8) fn(ii) {
WeekNames << ('Week ' + s(ii))
}

Weeks := {
WeekNames.1: week1.load
}
Weeks := StoryWeeks

WeekTexts := {
WeekNames.1: [
Expand All @@ -143,22 +156,22 @@ with scene('storyMode') fn {
]

WeekNames.5: [
'Mommy Mearest'
'The credits, thank the ones in it!'
'Christmas'
'Quit the game, boooring.'
]

WeekNames.6: [
'Christmas'
'Senpai'
'Quit the game, boooring.'
]

WeekNames.7: [
'Senpai'
'Tankman'
'Quit the game, boooring.'
]

WeekNames.8: [
'Tankman'
'WeekEnd 1'
'Quit the game, boooring.'
]
}
Expand Down Expand Up @@ -192,7 +205,7 @@ with scene('storyMode') fn {

// ---

with sm.EListen() with std.once() fn {
with sm.EListen() with Once() fn {
weekCall := sm.getItem()

Transition(BLACK).fadeIn(0.2)
Expand Down
33 changes: 32 additions & 1 deletion scenes/init/menu/weekLoading/all.oak
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
week1 := import('week1')
week1 := import('week1')
week2 := import('week2')
week3 := import('week3')
week4 := import('week4')
week5 := import('week5')
week6 := import('week6')
week7 := import('week7')
week8 := import('week8')

WeekCore := {
week1: week1
week2: week2
week3: week3
week4: week4
week5: week5
week6: week6
week7: week7
week8: week8
}

WeekKeys := keys(WeekCore)
WeekValues := Object.values(WeekCore)

fn addToThenRI(a, t, i) { a.(t |> s()) <- i, i }
fn addToWIn(t, i) addToThenRI(window, t, i)

// @Modder exposed
window.WeekHandler := {
WeekCore: addToWIn('WeekCore', WeekCore)
WeekKeys: addToWIn('WeekKeys', WeekKeys)
WeekValues: addToWIn('WeekValues', WeekValues)
}
Loading

0 comments on commit d8655c4

Please sign in to comment.