imj-base-0.1.0.2: Game engine with geometry, easing, animated text, delta rendering.

Safe HaskellNone
LanguageHaskell2010

Imj.GameItem.Weapon.Laser

Contents

Synopsis

Laser representations

LaserRay and Ray are parametrized by phantom types Theoretical and Actual to indicate if the ray was computed taking obstacles into account or not:

data LaserRay a Source #

A laser ray and the direction in which the laser was shot.

Constructors

LaserRay 

Fields

newtype Ray a Source #

A Laser ray

Constructors

Ray Segment 

data Theoretical Source #

The laser ray was computed ignoring obstacles

data Actual Source #

The laser ray was computed taking obstacles into account.

Laser reach

data LaserReach Source #

The reach of the laser.

Constructors

Infinite 

Create a Theoretical Ray

shootLaser and shootLaserWithOffset create a Theoretical ray, i.e it doesn't stop at obstacles:

shootLaser :: Coords Pos -> Direction -> LaserReach -> (Coords Pos -> Location) -> Maybe (Ray Theoretical) Source #

Creates a Ray by extending from a Coords until a collision is found.

shootLaserWithOffset Source #

Arguments

:: Coords Pos

Start coordinates

-> Direction

Direction of the shot

-> LaserReach 
-> (Coords Pos -> Location)

Collision function

-> Maybe (Ray Theoretical) 

Same as shootLaser but offsets the start Coords by one in the shot Direction.

Create an Actual Ray

computeActualLaserShot converts a Theoretical ray to an Actual ray, i.e it stops at obstacles (or not), according to LaserPolicy:

data LaserPolicy Source #

Tells which obstacles are destroyed on the Segment of Ray Theoretical

Constructors

DestroyFirstObstacle

The first obstacle is destroyed.

DestroyAllObstacles

All obstacles are destroyed.

computeActualLaserShot Source #

Arguments

:: [a]

Obstacles.

-> (a -> Coords Pos)

Obstacle to Coords function.

-> LaserRay Theoretical

The LaserRay that doesn't take obstacles into account.

-> LaserPolicy 
-> (([a], [a]), Maybe (LaserRay Actual)) 

Converts a Theoretical laser ray to an Actual one, taking obstacles and a LaserPolicy into account.

Returns a partition of obstacles between the remaining and the destroyed ones.

Utilities

afterEnd :: LaserRay Actual -> Coords Pos Source #

Returns the Coords that is just after the end of the LaserRay