Add 'game-sml/' from commit '113c3e67abe635f714f972a1e2ab0e4b24ff10f4'
git-subtree-dir: game-sml git-subtree-mainline:aa5357714dgit-subtree-split:113c3e67ab
This commit is contained in:
40
game-sml/fcore/title/title-update.sml
Normal file
40
game-sml/fcore/title/title-update.sml
Normal 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
|
||||
Reference in New Issue
Block a user