Safe Haskell | None |
---|---|
Language | Haskell2010 |
Game
Synopsis
- data GameState = Game {}
- initialStateFrom :: MapInfo -> MetaInfo -> GameState
- update :: Float -> GameState -> GameState
- render :: GameState -> Picture
- simulatedBallTrajectory :: MapInfo -> Position -> Vector -> Float -> Float -> [Point]
- type CollisionInfo = Maybe (SomeCollision, Float)
- data SomeCollision
- moveAndCollide :: Position -> Float -> Vector -> Float -> Float -> MapInfo -> (Vector, Vector, Float, CollisionInfo)
- moveAndBounceBall :: PlayerBall -> Float -> GameState -> GameState
- playerVelocityOnEnemyCollision :: Vector -> EnemyPeg -> Coords -> Vector
- getFirstEnemyIntersection :: Position -> Position -> [EnemyPeg] -> Float -> Maybe (EnemyPeg, Position)
- handleKeys :: Event -> GameState -> GameState
- updateMetaInfoSounds :: [Maybe String] -> MetaInfo -> MetaInfo
- allDestroyableBallsAreDestroyed :: GameState -> Bool
Documentation
A data structure to hold the state of the game.
Constructors
Game | |
initialStateFrom :: MapInfo -> MetaInfo -> GameState #
Generate initial game state depending on the map and metaInfo.
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.
Arguments
:: GameState | The game state to render. |
-> Picture | A picture of this game state. |
Convert a game state into a picture.
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).
data SomeCollision #
Different kinds of collisions.
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.
Arguments
:: PlayerBall | Player ball before move and bounce. |
-> Float | Seconds of game. |
-> GameState | Current |
-> GameState | New |
Move ball and bounce it off different obstacles, while changing the state of the game.
playerVelocityOnEnemyCollision #
Arguments
:: Vector |
|
-> EnemyPeg | Enemy ball for collision. |
-> Coords |
|
-> Vector | New |
Change player velocity when colliding with one enemy peg
handleKeys :: Event -> GameState -> GameState #
Respond to key events.
Updated MetaInfo
with List
of sounds ('Maybe String').
allDestroyableBallsAreDestroyed #
Check weather all balls that can be destroyed are destroyed.