Skip to content

Latest commit

 

History

History
185 lines (184 loc) · 4.33 KB

types.md

File metadata and controls

185 lines (184 loc) · 4.33 KB

Types Guide

Image

Use: The data-URI OR network path to image.
Note: Using network paths will cause the asset to be redownloaded to the clients if the clients cache is disabled.

type Image = String

X

Use: A horizontal displacement in number of pixels.
Note: Can be negative value.

type X = Int

Y

Use: A vertical displacement in number of pixels.
Note: Can be negative value.

type Y = Int

Width

Use: A horizontal width of an object in number of pixels.
Note: Cannot be negative.

type Width = Int

Height

Use: A vertical height of an object in number of pixels.
Note: Cannot be negative.

type Height = Int

FrameCount

Use: The number of Frames in a FrameArray
Note: Cannot be negative.

type FrameCount = Int

FramesPerSecond

Use: The number of screen updates that a Frames in a FrameArray will be displayed for before transitioning to the next frame.
Note: Cannot be negative.

type FramesPerSecond = Int

FrameArray

Use: A collection of Frames

type FrameArray = Array Image

Deg

Use: A angle in degrees.

type Deg = Int

AssetId

Use: A value that uniquely identifies a in-game asset (Image or Sprite).

type AssetId = Int

StateId

Use: A value that uniquely identifies a game state.

type StateId = Int

MapId

Use: A value that uniquely identifies a TileMap.

type MapId = Int

Score

Use: In game score

type Score = Int

TextHeight

Use: The height text should be in pixels when displayed on screen.

type TextHeight = Int

MonitorSize

Use: The Size of the canvas the game will be drawn on.

type MonitorSize = Size

Vector

Use: A change in X and Y coordinates.

type Vector = Position

Position

Use: A position relative with X and Y coordinates.

type Position = { 
  x :: X, 
  y :: Y
}

Velocity

Use: A speed with direction defined by a horizontal and vertical component.

type Velocity = {
  xSpeed :: Number,
  ySpeed :: Number 
}

Asset

Use: A collection of TileMaps

type Asset = { 
  mapData :: Array TileMap
}

TileMap

Use: A 2D array of ScaledImages. Any cell that is Nothing represents an empty tile.

type TileMap = Array (Array (Maybe ScaledImage))

DrawContext

Use: A graphical context for drawning TileMaps on a monitor with a defined Size given a Context2D.

type DrawContext = { 
  ctx :: Context2D, 
  mapData :: Array TileMap, 
  monitorSize :: MonitorSize
}

ScaledImage

Use: A Image with a defined Size and AssetId.

type ScaledImage = {
  id :: AssetId,
  image :: Image,
  size :: Size
}

Sprite

Use: A FrameArray that can be iterated through. Each of the images in the FrameArray will be scaled to the specified Size when drawn.
Note: frameIndex cannot be negative and frameCount should be the length of frames.

type Sprite = {
  id :: AssetId,
  frames :: FrameArray,
  frameIndex :: Int,
  framesPerSecond :: FramesPerSecond,
  frameCount :: FrameCount,
  size :: Size
}

Request

Use: An API request.

type Request = {
  url :: String,
  json :: String,
  method :: String
}

Size

Use: A wrapping type for an object's Width and Height.

type Size = {
  width :: Width,
  height :: Height
}

PlayerScoreCreateRequestData

Use: An API request for storing a player's score and time.

type PlayerScoreCreateRequestData = {
  username :: String,
  score :: Int,
  start :: String,
  end :: String
}

PlayerScore

Use: An API reqponse containg the details of a player's highscore.

type PlayerScore = {
    username :: String,
    score :: Int,
    time :: String,
    position :: Int
}