Orasund / elm-game-essentials / GJumper

The GJumper virtual console is a template for grid based games. It has the following Properties:

Here is a list of games that use this virtual console:

You can find the source files in the examples folder.

Main Type


type alias GameData square data =
{ data : data
, grid : Grid.Wrapped.Grid square
, player : ( Basics.Int
, Basics.Int ) 
}

The Model of a GJumper Game contains a player position, a grid and some aditional data.

You can define a square how ever you want. Any information, that can not be stored in the grid should be part of the data.


type Status
    = Ongoing
    | Won
    | Lost

At any point in time a game is either Ongoing, Won or Lost. Once the game is done, the game can be reset by pressing a buttion, some of the data can be also transfered from one game session to another (like a level counter).

Defining a Game

define : { init : Maybe data -> Random.Generator (InitModel square data), isSolid : square -> Basics.Bool, tick : GameData square data -> Random.Generator ( GameData square data, Status ), view : data -> View square, title : String, imgSize : Basics.Int, gameWon : List ( ( Basics.Float, Basics.Float ), PixelEngine.Image.Image Basics.Never ), gameOver : List ( ( Basics.Float, Basics.Float ), PixelEngine.Image.Image Basics.Never ) } -> Game square data

The main function of the game console.


type alias InitModel square data =
{ data : data
, player : ( Basics.Int
, Basics.Int )
, distribution : data -> ( ( Basics.Float
, Maybe square )
, List ( Basics.Float
, Maybe square ) )
, fixed : data -> List ( Basics.Int
, square )
, level : data -> List (List (Maybe square))
, rows : Basics.Int
, columns : Basics.Int 
}

The initial model.


type alias View square =
Core.View square

The view of the model

view : { player : PixelEngine.Tile.Tile Basics.Never, square : square -> PixelEngine.Tile.Tile Basics.Never } -> PixelEngine.Tile.Tileset -> PixelEngine.Background -> View square

Specifies how things look.

It uses the Tile from Orasund/pixelengine.

Additional Features

withGui : Header -> Footer -> PixelEngine.Background -> View square -> View square

Adds a Gui to the view.

footer : List ( Basics.Float, PixelEngine.Image.Image Basics.Never ) -> List ( Basics.Float, PixelEngine.Image.Image Basics.Never ) -> List ( Basics.Float, PixelEngine.Image.Image Basics.Never ) -> Footer

A footer. the floats specify the x position. It must be between 0 and 16*imgSize. The y position depends on the list (first list has y=0, second list has y=1 and third has y = 2)

header : List ( Basics.Float, PixelEngine.Image.Image Basics.Never ) -> Header

A header, the floats specify the x position. It must be between 0 and 16*imgSize.


type alias Footer =
Core.Footer

A Footer


type alias Header =
Core.Header

A header


type alias Game square model =
PixelEngine () (Model square model) Msg

The type of a game.