bouncing-crusher
Safe HaskellNone
LanguageHaskell2010

Game

Synopsis

Documentation

data GameState #

A data structure to hold the state of the game.

Constructors

Game 

Fields

Instances

Instances details
Show GameState # 
Instance details

Defined in Game

initialStateFrom :: MapInfo -> MetaInfo -> GameState #

Generate initial game state depending on the map and metaInfo.

update #

Arguments

:: Float

Time elapsed since last update.

-> GameState

Initial game state.

-> GameState

Updated game state.

Update the game by moving the ball and bouncing of walls and enemies.

render #

Arguments

:: GameState

The game state to render.

-> Picture

A picture of this game state.

Convert a game state into a picture.

simulatedBallTrajectory #

Arguments

:: MapInfo

Level.

-> Position

Start ball position.

-> Vector

Start ball direction.

-> Float

Start ball speed.

-> Float

dt of simulation.

-> [Point]

Path of the ball until the next collision.

Get path of simulated ball trajectory (radius is 1).

type CollisionInfo = Maybe (SomeCollision, Float) #

Collision with dtLeft or Nothing (no collision).

moveAndCollide #

Arguments

:: Position

Initial ball position.

-> Float

Elapsed time since last update.

-> Vector

Initial direction.

-> Float

Initial speed.

-> Float

Ball radius.

-> MapInfo

Level

-> (Vector, Vector, Float, CollisionInfo)

Tuple (newPoint, newDirection, newSpeed, collisionInfo).

Try to move ball in certain direction, get all collisions, apply gravity, get speed, direction, and position of either the point of first collision or simply next point of movement.

moveAndBounceBall #

Arguments

:: PlayerBall

Player ball before move and bounce.

-> Float

Seconds of game.

-> GameState

Current GameState.

-> GameState

New GameState

Move ball and bounce it off different obstacles, while changing the state of the game.

playerVelocityOnEnemyCollision #

Arguments

:: Vector

Vector of player ball before collision.

-> EnemyPeg

Enemy ball for collision.

-> Coords

Coords of collision point.

-> Vector

New Vector of player ball.

Change player velocity when colliding with one enemy peg

getFirstEnemyIntersection #

Arguments

:: Position

Player ball start Position.

-> Position

Player ball end Position.

-> [EnemyPeg]

Input List of EnemyPeg.

-> Float

Player ball radius.

-> Maybe (EnemyPeg, Position) 

handleKeys :: Event -> GameState -> GameState #

Respond to key events.

updateMetaInfoSounds #

Arguments

:: [Maybe String]

List of sounds.

-> MetaInfo

Input MetaInfo.

-> MetaInfo

New MetaInfo.

Updated MetaInfo with List of sounds ('Maybe String').

allDestroyableBallsAreDestroyed #

Arguments

:: GameState

Current GameState

-> Bool

Result of check.

Check weather all balls that can be destroyed are destroyed.