apecs-brillo: Apecs' gloss package, but adapted for brillo.

[ bsd3, game-engine, library, program ] [ Propose Tags ] [ Report a vulnerability ]

A library that's meant to bridge the gap between brillo and apecs.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.1.1, 0.2.0.0, 0.2.0.1 (info)
Change log CHANGELOG.md
Dependencies apecs (>=0.7 && <0.11), apecs-brillo, base (>=4.8 && <5), brillo (>=3 && <4), brillo-rendering (>=3 && <4), containers (>=0.5 && <0.8), linear (>=1.2 && <2) [details]
License BSD-3-Clause
Copyright 2017 Jonas Carpay, Execute
Author Execute
Maintainer Execute
Uploaded by execute214 at 2026-11-04T00:41:53Z
Revised Revision 1 made by AngelicaRakkaulikka at 2026-11-09T19:51:33Z
Category Game engine
Source repo head: git clone https://github.com/execute214/apecs-brillo
Distributions
Executables example-balls
Downloads 93 total (19 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for apecs-brillo-0.2.0.1

[back to package description]

apecs-brillo

The camera is already handled, you only have to pass in your own drawing, stepping and key handling functions. Check the Apecs.Brillo documentation to see the type signatures.

module Example where

import Apecs qualified
import Brillo qualified
import Apecs.Brillo qualified as Brillo
import System.Exit (exitSuccess)
import Control.Monad (void)
import Linear

newtype Position = Position (V2 Float)
  deriving Show

instance Apecs.Component Position where
  type Storage Position = Apecs.Map Position

newtype Velocity = Velocity (V2 Float)
  deriving Show

instance Apecs.Component Velocity where
  type Storage Velocity = Apecs.Map Velocity

Apecs.makeWorld "World"
  [ ''Brillo.Camera
  , ''Position
  , ''Velocity
  ]

main :: IO ()
main = do
  world <- initWorld
  Apecs.runWith world do
    initialise
    Brillo.playWithApecs (Brillo.InWindow "Example" (800, 600) (10, 10)) Brillo.black 60 draw handleEvent step

initialise :: Apecs.System World ()
initialise = void do
  Apecs.newEntity (Position 0, Velocity (V2 12 (-16)))
  Apecs.newEntity (Position (V2 24 0), Velocity (V2 (-48) 8))
  Apecs.newEntity (Position (V2 48 24), Velocity (V2 32 16))

step :: Float -> Apecs.System World ()
step dT = do
  velocity dT
  gravity dT

velocity :: Float -> Apecs.System World ()
velocity dT = Apecs.cmap \(Position pos, Velocity vel) -> Position $ pos + vel ^* dT

gravity :: Float -> Apecs.System World ()
gravity dT = Apecs.cmap \(Velocity vel) -> Velocity $ vel + gravityVel ^* dT
  where gravityVel = V2 0 (-1)

handleEvent :: Brillo.Event -> Apecs.System World ()
handleEvent = \case
  Brillo.EventKey (Brillo.SpecialKey Brillo.KeyEsc) Brillo.Down _ _ -> Apecs.liftIO exitSuccess
  _ -> pure ()

draw :: Apecs.System World Brillo.Picture
draw = do
  drawnEntities <- Brillo.cfoldDraw \(Position (V2 x y)) -> Brillo.Translate x y $ Brillo.circleSolid 10

  pure $ Brillo.Color (Brillo.makeColorI 255 255 255 255) drawnEntities```