refactor player.sml for easier extensibility when fields are added to player type (we accept a list of values to change, instead of destructuring the player.sml values on each function call)

This commit is contained in:
2024-12-22 05:40:33 +00:00
parent 05ec1880d2
commit e2b89af6ac
3 changed files with 502 additions and 396 deletions

View File

@@ -6,6 +6,7 @@ struct
, rightHeld = ref false
, upHeld = ref false
, downHeld = ref false
, attackHeld = ref false
, width = ref (1920.0 : Real32.real)
, height = ref (1080.0 : Real32.real)
}
@@ -15,6 +16,7 @@ struct
, rightHeld = !(#rightHeld state)
, upHeld = !(#upHeld state)
, downHeld = !(#downHeld state)
, attackHeld = !(#attackHeld state)
}
fun getWidth () =
@@ -45,6 +47,10 @@ struct
if action = PRESS then (#rightHeld state) := true
else if action = RELEASE then (#rightHeld state) := false
else ()
else if key = KEY_J then
if action = PRESS then (#attackHeld state) := true
else if action = RELEASE then (#attackHeld state) := false
else ()
else
()