LambdaHack-0.5.0.0: A game engine library for roguelike dungeon crawlers

Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.Time

Description

Game time and speed.

Synopsis

Documentation

data Time Source #

Game time in ticks. The time dimension. One tick is 1 microsecond (one millionth of a second), one turn is 0.5 s.

Instances

Bounded Time Source # 
Enum Time Source # 

Methods

succ :: Time -> Time #

pred :: Time -> Time #

toEnum :: Int -> Time #

fromEnum :: Time -> Int #

enumFrom :: Time -> [Time] #

enumFromThen :: Time -> Time -> [Time] #

enumFromTo :: Time -> Time -> [Time] #

enumFromThenTo :: Time -> Time -> Time -> [Time] #

Eq Time Source # 

Methods

(==) :: Time -> Time -> Bool #

(/=) :: Time -> Time -> Bool #

Ord Time Source # 

Methods

compare :: Time -> Time -> Ordering #

(<) :: Time -> Time -> Bool #

(<=) :: Time -> Time -> Bool #

(>) :: Time -> Time -> Bool #

(>=) :: Time -> Time -> Bool #

max :: Time -> Time -> Time #

min :: Time -> Time -> Time #

Show Time Source # 

Methods

showsPrec :: Int -> Time -> ShowS #

show :: Time -> String #

showList :: [Time] -> ShowS #

Binary Time Source # 

Methods

put :: Time -> Put #

get :: Get Time #

putList :: [Time] -> Put #

timeZero :: Time Source #

Start of the game time, or zero lenght time interval.

timeClip :: Time Source #

At least once per clip all moves are resolved and a frame or a frame delay is generated. Currently one clip is 0.1 s, but it may change, and the code should not depend on this fixed value.

timeTurn :: Time Source #

One turn is 0.5 s. The code may depend on that. Actors at normal speed (2 m/s) take one turn to move one tile (1 m by 1 m).

timeEpsilon :: Time Source #

An infinitesimal time period.

absoluteTimeAdd :: Time -> Time -> Time Source #

Absolute time addition, e.g., for summing the total game session time from the times of individual games.

absoluteTimeNegate :: Time -> Time Source #

Absolute time negation. To be used for reversing time flow, e.g., for comparing absolute times in the reverse order.

timeFit :: Time -> Time -> Int Source #

How many time intervals of the latter kind fits in an interval of the former kind.

timeFitUp :: Time -> Time -> Int Source #

How many time intervals of the latter kind cover an interval of the former kind (rounded up).

newtype Delta a Source #

One-dimentional vectors. Introduced to tell apart the 2 uses of Time: as an absolute game time and as an increment.

Constructors

Delta a 

Instances

Functor Delta Source # 

Methods

fmap :: (a -> b) -> Delta a -> Delta b #

(<$) :: a -> Delta b -> Delta a #

Bounded a => Bounded (Delta a) Source # 

Methods

minBound :: Delta a #

maxBound :: Delta a #

Enum a => Enum (Delta a) Source # 

Methods

succ :: Delta a -> Delta a #

pred :: Delta a -> Delta a #

toEnum :: Int -> Delta a #

fromEnum :: Delta a -> Int #

enumFrom :: Delta a -> [Delta a] #

enumFromThen :: Delta a -> Delta a -> [Delta a] #

enumFromTo :: Delta a -> Delta a -> [Delta a] #

enumFromThenTo :: Delta a -> Delta a -> Delta a -> [Delta a] #

Eq a => Eq (Delta a) Source # 

Methods

(==) :: Delta a -> Delta a -> Bool #

(/=) :: Delta a -> Delta a -> Bool #

Ord a => Ord (Delta a) Source # 

Methods

compare :: Delta a -> Delta a -> Ordering #

(<) :: Delta a -> Delta a -> Bool #

(<=) :: Delta a -> Delta a -> Bool #

(>) :: Delta a -> Delta a -> Bool #

(>=) :: Delta a -> Delta a -> Bool #

max :: Delta a -> Delta a -> Delta a #

min :: Delta a -> Delta a -> Delta a #

Show a => Show (Delta a) Source # 

Methods

showsPrec :: Int -> Delta a -> ShowS #

show :: Delta a -> String #

showList :: [Delta a] -> ShowS #

Binary a => Binary (Delta a) Source # 

Methods

put :: Delta a -> Put #

get :: Get (Delta a) #

putList :: [Delta a] -> Put #

timeShift :: Time -> Delta Time -> Time Source #

Shifting an absolute time by a time vector.

timeDeltaToFrom :: Time -> Time -> Delta Time Source #

Time time vector between the second and the first absolute times. The arguments are in the same order as in the underlying scalar subtraction.

timeDeltaSubtract :: Delta Time -> Delta Time -> Delta Time Source #

Time time vector between the second and the first absolute times. The arguments are in the same order as in the underlying scalar subtraction.

timeDeltaReverse :: Delta Time -> Delta Time Source #

Reverse a time vector.

timeDeltaScale :: Delta Time -> Int -> Delta Time Source #

Scale the time vector by an Int scalar value.

timeDeltaToDigit :: Delta Time -> Delta Time -> Char Source #

Represent the main 10 thresholds of a time range by digits, given the total length of the time range.

ticksPerMeter :: Speed -> Delta Time Source #

The number of time ticks it takes to walk 1 meter at the given speed.

data Speed Source #

Speed in meters per 1 million seconds (m/Ms). Actors at normal speed (2 m/s) take one time turn (0.5 s) to make one step (move one tile, which is 1 m by 1 m).

Instances

Eq Speed Source # 

Methods

(==) :: Speed -> Speed -> Bool #

(/=) :: Speed -> Speed -> Bool #

Ord Speed Source # 

Methods

compare :: Speed -> Speed -> Ordering #

(<) :: Speed -> Speed -> Bool #

(<=) :: Speed -> Speed -> Bool #

(>) :: Speed -> Speed -> Bool #

(>=) :: Speed -> Speed -> Bool #

max :: Speed -> Speed -> Speed #

min :: Speed -> Speed -> Speed #

Show Speed Source # 

Methods

showsPrec :: Int -> Speed -> ShowS #

show :: Speed -> String #

showList :: [Speed] -> ShowS #

Binary Speed Source # 

Methods

put :: Speed -> Put #

get :: Get Speed #

putList :: [Speed] -> Put #

toSpeed :: Int -> Speed Source #

Constructor for content definitions.

fromSpeed :: Speed -> Int Source #

Pretty-printing of speed in the format used in content definitions.

speedZero :: Speed Source #

No movement possible at that speed.

speedNormal :: Speed Source #

Normal speed (2 m/s) that suffices to move one tile in one turn.

speedScale :: Rational -> Speed -> Speed Source #

Scale speed by an Int scalar value.

timeDeltaDiv :: Delta Time -> Int -> Delta Time Source #

Divide a time vector.

speedAdd :: Speed -> Speed -> Speed Source #

Speed addition.

speedNegate :: Speed -> Speed Source #

Speed negation.

speedFromWeight :: Int -> Int -> Speed Source #

Calculate projectile speed from item weight in grams and velocity percent modifier. See https://github.com/LambdaHack/LambdaHack/wiki/Item-statistics.

rangeFromSpeed :: Speed -> Int Source #

Calculate maximum range in meters of a projectile from its speed. See https://github.com/LambdaHack/LambdaHack/wiki/Item-statistics. With this formula, each projectile flies for at most 1 second, that is 2 turns, and then drops to the ground.

rangeFromSpeedAndLinger :: Speed -> Int -> Int Source #

Calculate maximum range taking into account the linger percentage.