Reactor.Action
- Package
- purescript-grid-reactors
- Repository
- Eugleo/purescript-grid-reactors
#Action Source
#utilities Source
utilities :: forall world m. Action m world Utilities
Get a record of the following:
bound :: CoordinateSystem Point -> CoordinateSystem Point
, a function that bounds the given point in the grid or the canvas, meaning the point won't be beyond the bounds of its coordinate system.height :: Int
,width :: Int
, the dimensions of the gridcellSize :: Int
the size of one grid cell, in points. The size is set internally, and this is the only way to its value.
#randomPositive Source
randomPositive :: forall world m. Int -> Action m world Int
Get a random non-negative integer smaller than the given upper bound (inclusive). The distribution of these integers is discrete uniform.
#randomInRange Source
randomInRange :: forall world m. Int -> Int -> Action m world Int
Get a random integer between the given bounds (inclusive). The distribution of these integers is discrete uniform.
#togglePause Source
togglePause :: forall world m. Action m { paused :: Boolean | world } Unit
Toggle the paused
attribute of the world from false
to true
and vice versa.
A shorthand for
modify_ \w -> w { paused = not w.paused }
#preventDefaultBehavior Source
preventDefaultBehavior :: forall world m. Action m { paused :: Boolean | world } DefaultBehavior
Prevent the execution of the default behavior associated with the event.
You can read more in the documentation of Reactor.Events
.
Usually, this or executeDefaultBehavior
is the last thing you'll call in
your onMouse
and onKey
handlers. This one will usually get called in
the events you handle (i.e. that have some functionality associated with them in your game).
#executeDefaultBehavior Source
executeDefaultBehavior :: forall world m. Action m { paused :: Boolean | world } DefaultBehavior
After handling the event, execute the default behavior as well.
You can read more in the documentation of Reactor.Events
.
Usually, this or preventDefaultBehavior
is the last thing you'll call in
your onMouse
and onKey
handlers. This one will usually get called in
the events you only let pass through (i.e. when pressing 'J' doesn't 'do anything' in your game).
#ActionF Source
data ActionF :: (Type -> Type) -> Type -> Type -> Type
data ActionF m world a
A DSL for constructing actions. Mostly for internal use.
Most of the time, you construct an action by calling the different helper functions
in this module, like modify_
, instead of building an ActionF
manually.
Constructors
RandomNumber Int Int (Int -> a)
Lift (m a)
Modify (world -> world) (world -> a)
Utilities (Utilities -> a)
Instances
#Utilities Source
type Utilities = { bound :: CoordinateSystem Point -> CoordinateSystem Point, cellSize :: Int, height :: Int, width :: Int }