linsyking/messenger-core/8.2.3

NOTE: the latest version is 20.0.0

Renamed to elm-messenger/messenger-core. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as linsyking/messenger-core still install under that name. 34 versions of 52 come from the new location (see their notes). 7 versions could not be recovered and cannot be installed.

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/elm-messenger/messenger-core.

What we checked: The repo moved to github.com/elm-messenger/messenger-core. Rebuilt with git archive from commit 99fe27eec085 of https://github.com/elm-messenger/messenger-core (zip prefix linsyking-messenger-core-fb7509b/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 cdb1082c9e589b7fd90b9f6f2fb643f909f8930f.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/linsyking/messenger-core/zipball/8.2.3/

Messenger.Base

Base Module

Some Basic Data Types for the game

= Tick Posix
| KeyDown Int
| KeyUp Int
| NewWindowSize ( Float, Float )
| WindowVisibility Visibility
| SoundLoaded String AudioOption (Result LoadError Source)
| PlaySoundGotTime String AudioOption Source Posix
| TextureLoaded String (Maybe Texture)
| MouseDown Int ( Float, Float )
| MouseUp Int ( Float, Float )
| MouseMove ( Float, Float )
| MouseWheel Int
| Prompt String String
| NullEvent

World Event

This is the World Event for the game.

Users can get outside information through the events.

Tick records the time.

KeyDown, KeyUp records the keyboard events

MouseDown, MouseUp records the button code and position when mouse up and down

MouseWheel records the wheel event for mouse, it can be also used for touchpad

Note: Do Not use MouseMove Event to get mouse position. Use Globaldata instead.

type alias GlobalData userdata =
{ internalData : InternalData
, sceneStartTime : Int
, globalTime : Int
, currentTimeStamp : Posix
, windowVisibility : Visibility
, mousePos : ( Float, Float )
, pressedMouseButtons : Set Int
, pressedKeys : Set Int
, extraHTML : Maybe (Html WorldEvent)
, canvasAttributes : List (Attribute WorldEvent)
, volume : Float
, userData : userdata
, currentScene : String
}

GlobalData

GlobalData is the data that doesn't change during the game.

It won't be reset if you change the scene.

It is mainly used for display and reading/writing some localstorage data.

  • globalTime records the past frames number since the game started
  • sceneStartTime records the past frames number since this scene started
  • userdata records the data that users set to save
  • extraHTML is used to render extra HTML tags. Be careful to use this
  • windowVisibility records whether users stay in this tab/window
  • pressedKeys records the keycodes that are be pressed now
  • pressedMouseButtons records the mouse buttons that are pressed now
type alias InternalData =
{ browserViewPort : ( Float, Float )
, realWidth : Float
, realHeight : Float
, startLeft : Float
, startTop : Float
, sprites : Dict String Texture
, virtualWidth : Float
, virtualHeight : Float
}

Internal GlobalData

Basically users do not need to get or modify them.

  • browserViewPort records the browser size.
  • sprites records all the sprites(images).
type alias Env common userdata =
{ globalData : GlobalData userdata
, commonData : common
}

Environment

Environment is provided to users almost all the time.

It stores GlobalData and CommonData (Similar to GlobalData but just for one scene), so you can get and modify them through the Env.

type alias Flags =
{ windowWidth : Float
, windowHeight : Float
, timeStamp : Int
, info : String
}

Flags

The main flags. Get info from js script.

Learn more about flags here

removeCommonData : Env cdata userdata -> Env () userdata

Remove common data from environment.

Useful when dealing with portable components by yourself.

Most of the time it will not be used since it has been built into prepared update functions.

addCommonData : cdata -> Env () userdata -> Env cdata userdata

Add the common data to a Environment without common data.

type alias UserViewGlobalData userdata =
{ sceneStartTime : Int
, globalTime : Int
, volume : Float
, extraHTML : Maybe (Html WorldEvent)
, canvasAttributes : List (Attribute WorldEvent)
, userData : userdata
}

UserViewGlobalData

This type is for user to use when initializing the messenger.

emptyInternalData : InternalData

Empty InternalData

userGlobalDataToGlobalData : UserViewGlobalData userdata -> GlobalData userdata

Translate UserViewGlobalData to GlobalData

globalDataToUserGlobalData : GlobalData userdata -> UserViewGlobalData userdata

Translate GlobalData to UserViewGlobalData