36 lines
828 B
Standard ML
36 lines
828 B
Standard ML
|
|
structure MoveMode =
|
||
|
|
struct
|
||
|
|
open AppType
|
||
|
|
open InputMessage
|
||
|
|
|
||
|
|
fun makeBlankYAxis length =
|
||
|
|
Vector.tabulate (length, fn _ => {r = 0, g = 0, b = 0, a = 0})
|
||
|
|
|
||
|
|
fun moveImageUp (model: app_type) =
|
||
|
|
let
|
||
|
|
val {squares, ...} = model
|
||
|
|
|
||
|
|
val squares =
|
||
|
|
Vector.mapi
|
||
|
|
(fn (idx, yAxis) =>
|
||
|
|
if idx + 1 < Vector.length squares then
|
||
|
|
Vector.sub (squares, idx + 1)
|
||
|
|
else
|
||
|
|
makeBlankYAxis (Vector.length yAxis)) squares
|
||
|
|
|
||
|
|
val model = AppWith.squares (model, squares)
|
||
|
|
in
|
||
|
|
(model, [])
|
||
|
|
end
|
||
|
|
|
||
|
|
fun update (model, inputMsg) =
|
||
|
|
case inputMsg of
|
||
|
|
ARROW_UP => moveImageUp model
|
||
|
|
(*
|
||
|
|
| ARROW_LEFT => moveImageLeft model
|
||
|
|
| ARROW_RIGHT => moveImageRight model
|
||
|
|
| ARROW_DOWN => moveImageDown model
|
||
|
|
*)
|
||
|
|
| _ => (model, [])
|
||
|
|
end
|