Orasund/pixelengine/3.0.0

NOTE: the latest version is 6.2.0

PixelEngine.Controls

The graphic engine provides a touch-controller for mobile devices. The controllers has 8 buttons: Left (a key), Right (d key), Up (w key), Down (s key), A(Spacebar), B(x key), X(q key), Y(e key)

Main Function

{ windowSize :
{ width : Float
, height : Float
}
, controls : Input -> msg
}
-> Options msg
-> Options msg

adds mobile support to the options. It needs the window size.

PixelEngine provides a fully wired program that takes care of everything.

Input

type Input
= InputLeft
| InputRight
| InputUp
| InputDown
| InputA
| InputB
| InputX
| InputY
| InputNone

all possible Inputs

defaultLayout : String -> Input

the default layout:

  • A/ArrowLeft - InputLeft
  • W/ArrowUp - InputUp
  • D/ArrowRight - InputRight
  • S/ArrowDown - InputDown
  • Space/Enter - InputA
  • X/Backspace/Esc - InputB
  • Q - InputX
  • E - InputY

Subscriptions

basic : (Input -> msg) -> Sub msg

subscribes to a keypress and sends the corresponding msg. This Function uses the default key layout.

custom : (String -> Input) -> (Input -> msg) -> Sub msg

subscribes to a keypress using custom key layouts it uses key values for the String. You can use this website to find out the key value.