Add 'game-sml/' from commit '113c3e67abe635f714f972a1e2ab0e4b24ff10f4'

git-subtree-dir: game-sml
git-subtree-mainline: aa5357714d
git-subtree-split: 113c3e67ab
This commit is contained in:
2026-04-24 00:38:14 +01:00
174 changed files with 337598 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
signature TITLE_TYPE =
sig
datatype focus = START_BUTTON | OPTIONS_BUTTON
type title_type = {focus: focus}
val initial: title_type
end
structure TitleType :> TITLE_TYPE =
struct
datatype focus = START_BUTTON | OPTIONS_BUTTON
type title_type = {focus: focus}
val initial = {focus = START_BUTTON}
end

View File

@@ -0,0 +1,40 @@
structure TitleUpdate =
struct
open TitleType
fun update (titleState, input: FrameInputType.t, userKeys, time) =
case #focus titleState of
START_BUTTON =>
let
val mode =
if CoreKey.containsAttack (userKeys, #newKeys input) then
GameType.LEVEL LevelType.initial
else
let
val titleState =
if #downHeld input then {focus = OPTIONS_BUTTON}
else titleState
in
GameType.TITLE titleState
end
in
{mode = mode, userKeys = userKeys, saveKeys = false}
end
| OPTIONS_BUTTON =>
let
val mode =
if CoreKey.containsAttack (userKeys, #newKeys input) then
let val options = OptionsType.init userKeys
in GameType.OPTIONS options
end
else
let
val titleState =
if #upHeld input then {focus = START_BUTTON} else titleState
in
GameType.TITLE titleState
end
in
{mode = mode, userKeys = userKeys, saveKeys = false}
end
end

View File

@@ -0,0 +1,31 @@
structure TitleVec =
struct
open TitleType
fun getDrawVec (title: TitleType.title_type, width, height) =
case #focus title of
START_BUTTON =>
let
val playX = MakeTextVec.getTextCentreX "Play game"
val acc = MakeTextVec.make
(playX, 500, width, height, "Play game", 0.3, 0.3, 0.7, [])
val optionsX = MakeTextVec.getTextCentreX "Options"
val acc = MakeTextVec.make
(optionsX, 600, width, height, "Options", 0.0, 0.0, 0.0, acc)
in
Vector.concat acc
end
| OPTIONS_BUTTON =>
let
val playX = MakeTextVec.getTextCentreX "Play game"
val acc = MakeTextVec.make
(playX, 500, width, height, "Play game", 0.0, 0.0, 0.0, [])
val optionsX = MakeTextVec.getTextCentreX "Options"
val acc = MakeTextVec.make
(optionsX, 600, width, height, "Options", 0.3, 0.3, 0.7, acc)
in
Vector.concat acc
end
end