Cosmetic - adjust comment format

This commit is contained in:
Tony Garnock-Jones 2015-10-23 13:09:32 -04:00
parent 0ddda2aebe
commit 9da90088b6
1 changed files with 223 additions and 228 deletions

View File

@ -6,234 +6,229 @@
(require plot/utils) ;; for vector utilities (require plot/utils) ;; for vector utilities
(require prospect-gl/2d) (require prospect-gl/2d)
#| ;; Layers:
;;
Layers: ;; - External I/O
;; as arranged by prospect-gl/2d
- External I/O ;; including keyboard events, interface to rendering, and frame timing
as arranged by prospect-gl/2d ;;
including keyboard events, interface to rendering, and frame timing ;; - Ground
;; corresponds to computer itself
- Ground ;; device drivers
corresponds to computer itself ;; applications (e.g. in this instance, the game)
device drivers ;;
applications (e.g. in this instance, the game) ;; - Game
;; running application
- Game ;; per-game state, such as score and count-of-deaths
running application ;; process which spawns levels
per-game state, such as score and count-of-deaths ;; regular frame ticker
process which spawns levels ;;
regular frame ticker ;; - Level
;; model of the game world
- Level ;; actors represent entities in the world, mostly
model of the game world ;; misc actors do physicsish things
actors represent entities in the world, mostly ;;
misc actors do physicsish things ;; ## Common Data Definitions
;;
## Common Data Definitions ;; A Vec is a (vector Number Number)
;; A Point is a (vector Number Number)
A Vec is a (vector Number Number) ;; (See vector functions in plot/utils)
A Point is a (vector Number Number) ;;
(See vector functions in plot/utils) ;; ## Ground Layer Protocols
;;
## Ground Layer Protocols ;; - Scene Management
;; - assertion: ScrollOffset
- Scene Management ;; - role: SceneManager
- assertion: ScrollOffset ;; Displays the scene backdrop and adjusts display coordinates via ScrollOffset.
- role: SceneManager ;;
Displays the scene backdrop and adjusts display coordinates via ScrollOffset. ;; A ScrollOffset is a (scroll-offset Vec), indicating the vector to *subtract*
;; from world coordinates to get device coordinates.
A ScrollOffset is a (scroll-offset Vec), indicating the vector to *subtract* ;;
from world coordinates to get device coordinates. ;; ## Game Layer Protocols
;;
## Game Layer Protocols ;; - Scoring
;; - message: AddToScore
- Scoring ;; - assertion: CurrentScore
- message: AddToScore ;; - role: ScoreKeeper
- assertion: CurrentScore ;; Maintains the score as private state.
- role: ScoreKeeper ;; Publishes the score using a CurrentScore.
Maintains the score as private state. ;; Responds to AddToScore by updating the score.
Publishes the score using a CurrentScore. ;;
Responds to AddToScore by updating the score. ;; - Level Spawning
;; - assertion: LevelRunning
- Level Spawning ;; - message: LevelCompleted
- assertion: LevelRunning ;; - role: LevelSpawner
- message: LevelCompleted ;; Maintains the current level number as private state.
- role: LevelSpawner ;; Spawns a new Level when required.
Maintains the current level number as private state. ;; Monitors LevelRunning - when it drops, the level is over.
Spawns a new Level when required. ;; Receives LevelCompleted messages. If LevelRunning drops without
Monitors LevelRunning - when it drops, the level is over. ;; a LevelCompleted having arrived, the level ended in failure and
Receives LevelCompleted messages. If LevelRunning drops without ;; should be restarted. If LevelComplete arrived before LevelRunning
a LevelCompleted having arrived, the level ended in failure and ;; dropped, the level was completed successfully, and the next level
should be restarted. If LevelComplete arrived before LevelRunning ;; should be presented.
dropped, the level was completed successfully, and the next level ;; - role: Level
should be presented. ;; Running level instance. Maintains LevelRunning while it's still
- role: Level ;; going. Sends LevelCompleted if the player successfully completed
Running level instance. Maintains LevelRunning while it's still ;; the level.
going. Sends LevelCompleted if the player successfully completed ;;
the level. ;; An AddToScore is an (add-to-score Number), a message
;; which signals a need to add the given number to the player's
An AddToScore is an (add-to-score Number), a message ;; current score.
which signals a need to add the given number to the player's ;;
current score. ;; A CurrentScore is a (current-score Number), an assertion
;; indicating the player's current score.
A CurrentScore is a (current-score Number), an assertion ;;
indicating the player's current score. ;; A LevelRunning is a (level-running), an assertion indicating that the
;; current level is still in progress.
A LevelRunning is a (level-running), an assertion indicating that the ;;
current level is still in progress. ;; A LevelCompleted is a (level-completed), a message indicating that
;; the current level was *successfully* completed before it terminated.
A LevelCompleted is a (level-completed), a message indicating that ;;
the current level was *successfully* completed before it terminated. ;; ## Level Layer Protocols
;;
## Level Layer Protocols ;; - Movement and Physics
;; - message: JumpRequest
- Movement and Physics ;; - assertion: Impulse
- message: JumpRequest ;; - assertion: Velocity
- assertion: Impulse ;; - assertion: Position
- assertion: Velocity ;; - assertion: Massive
- assertion: Position ;; - assertion: Attribute
- assertion: Massive ;; - assertion: InitialPosition
- assertion: Attribute ;; - role: PhysicsEngine
- assertion: InitialPosition ;; Maintains positions, velocities and accelerations of all GamePieces.
- role: PhysicsEngine ;; Uses InitialPosition to place a piece at its creation.
Maintains positions, velocities and accelerations of all GamePieces. ;; Publishes Velocity and Position to match.
Uses InitialPosition to place a piece at its creation. ;; Listens to FrameDescription, using it to advance the simulation.
Publishes Velocity and Position to match. ;; Takes Impulses as the baseline for moving GamePieces around.
Listens to FrameDescription, using it to advance the simulation. ;; For Massive GamePieces, applies gravitational acceleration.
Takes Impulses as the baseline for moving GamePieces around. ;; Computes collisions between GamePieces.
For Massive GamePieces, applies gravitational acceleration. ;; Uses Attributed Aspects of GamePieces to decide what to do in response.
Computes collisions between GamePieces. ;; Sometimes, this involves sending Damage.
Uses Attributed Aspects of GamePieces to decide what to do in response. ;; Responds to JumpRequest by checking whether the named piece is in a
Sometimes, this involves sending Damage. ;; jumpable location, and sets its upward velocity negative if so.
Responds to JumpRequest by checking whether the named piece is in a ;; Consumer of LevelSize to figure out regions where, if a GamePiece
jumpable location, and sets its upward velocity negative if so. ;; crosses into them, Damage should be dealt to the piece.
Consumer of LevelSize to figure out regions where, if a GamePiece ;; When the player touches a goal, sends LevelCompleted one layer out and
crosses into them, Damage should be dealt to the piece. ;; then kills the world. When the player vanishes from the board, kills
When the player touches a goal, sends LevelCompleted one layer out and ;; the world.
then kills the world. When the player vanishes from the board, kills ;; - role: GamePiece
the world. ;; Maintains private state. Asserts Impulse to move around, asserts Massive
- role: GamePiece ;; and Attribute as required, asserts InitialPosition to get things
Maintains private state. Asserts Impulse to move around, asserts Massive ;; started. May issue JumpRequests at any time. Represents both the player,
and Attribute as required, asserts InitialPosition to get things ;; enemies, the goal(s), and platforms and blocks in the environment.
started. May issue JumpRequests at any time. Represents both the player, ;; Asserts a Sprite two layers out to render itself.
enemies, the goal(s), and platforms and blocks in the environment. ;;
Asserts a Sprite two layers out to render itself. ;; - Player State
;; - message: Damage
- Player State ;; - assertion: Health
- message: Damage ;; - role: Player
- assertion: Health ;; Maintains hitpoints, which it reflects using Health.
- role: Player ;; Responds to Damage.
Maintains hitpoints, which it reflects using Health. ;; When hitpoints drop low enough, removes the player from the board.
Responds to Damage. ;;
When hitpoints drop low enough, removes the player from the board. ;; - World State
;; - assertion: LevelSize
- World State ;; - role: DisplayControl
- assertion: LevelSize ;; Maintains a LevelSize assertion.
- role: DisplayControl ;; Observes the Position of the player, and computes and maintains a
Maintains a LevelSize assertion. ;; ScrollOffset two layers out, to match.
Observes the Position of the player, and computes and maintains a ;;
ScrollOffset two layers out, to match. ;; An ID is a Symbol; the special symbol 'player indicates the player's avatar.
;; Gensyms from (gensym 'enemy) name enemies, etc.
An ID is a Symbol; the special symbol 'player indicates the player's avatar. ;;
Gensyms from (gensym 'enemy) name enemies, etc. ;; A JumpRequest is a (jump-request ID), a message indicating a *request* to jump,
;; not necessarily honoured by the physics engine.
A JumpRequest is a (jump-request ID), a message indicating a *request* to jump, ;;
not necessarily honoured by the physics engine. ;; An Impulse is an (impulse ID Vec), an assertion indicating a contribution to
;; the net *requested* velocity of the given gamepiece.
An Impulse is an (impulse ID Vec), an assertion indicating a contribution to ;;
the net *requested* velocity of the given gamepiece. ;; A Velocity is a (velocity ID Vec), an assertion describing the net *actual*
;; velocity of the named gamepiece.
A Velocity is a (velocity ID Vec), an assertion describing the net *actual* ;;
velocity of the named gamepiece. ;; A Position is a (position ID Point), an assertion describing the current actual
;; position of the named gamepiece.
A Position is a (position ID Point), an assertion describing the current actual ;;
position of the named gamepiece. ;; A Massive is a (massive ID), an assertion noting that the named gamepiece
;; should be subject to the effects of gravity.
A Massive is a (massive ID), an assertion noting that the named gamepiece ;;
should be subject to the effects of gravity. ;; An Attribute is an (attribute ID Aspect), an assertion describing some aspect of
;; the named gamepiece
An Attribute is an (attribute ID Aspect), an assertion describing some aspect of ;;
the named gamepiece ;; An Aspect is either
;; - 'player - the named piece is a player avatar
An Aspect is either ;; - 'enemy - the named piece is an enemy
- 'player - the named piece is a player avatar ;; - 'solid - the named piece can be stood on / jumped from
- 'enemy - the named piece is an enemy ;; - 'goal - the named piece, if touched, causes the level to
- 'solid - the named piece can be stood on / jumped from ;; End The Game In Victory
- 'goal - the named piece, if touched, causes the level to ;;
End The Game In Victory ;; An InitialPosition is an (initial-position ID Point), an assertion specifying
;; not only the *existence* but also the initial position (in World coordinates)
An InitialPosition is an (initial-position ID Point), an assertion specifying ;; of the named gamepiece.
not only the *existence* but also the initial position (in World coordinates) ;;
of the named gamepiece. ;; A Damage is a (damage ID Number), a message indicating an event that should
;; consume the given number of health points of the named gamepiece.
A Damage is a (damage ID Number), a message indicating an event that should ;;
consume the given number of health points of the named gamepiece. ;; A Health is a (health ID Number), an assertion describing the current hitpoints
;; of the named gamepiece.
A Health is a (health ID Number), an assertion describing the current hitpoints ;;
of the named gamepiece. ;; A LevelSize is a (level-size Vec), an assertion describing the right-hand and
;; bottom edges of the level canvas (in World coordinates).
A LevelSize is a (level-size Vec), an assertion describing the right-hand and ;;
bottom edges of the level canvas (in World coordinates). ;; -----------
;; Interaction Diagrams (to be refactored into the description later)
----------- ;;
Interaction Diagrams (to be refactored into the description later) ;; ================================================================================
;;
================================================================================ ;; title Jump Sequence
;;
title Jump Sequence ;; Player -> Physics: (jump 'player)
;; note right of Physics: Considers the request.
Player -> Physics: (jump 'player) ;; note right of Physics: Denied -- Player is not on a surface.
note right of Physics: Considers the request. ;;
note right of Physics: Denied -- Player is not on a surface. ;; Player -> Physics: (jump 'player)
;; note right of Physics: Considers the request.
Player -> Physics: (jump 'player) ;; note right of Physics: Accepted.
note right of Physics: Considers the request. ;; note right of Physics: Updates velocity, position
note right of Physics: Accepted. ;; Physics -> Subscribers: (vel 'player ...)
note right of Physics: Updates velocity, position ;; Physics -> Subscribers: (pos 'player ...)
Physics -> Subscribers: (vel 'player ...) ;;
Physics -> Subscribers: (pos 'player ...) ;;
;; ================================================================================
;;
================================================================================ ;; title Display Control Updates
;;
title Display Control Updates ;; Physics -> DisplayCtl: (pos 'player ...)
;; note right of DisplayCtl: Compares player pos to level size
Physics -> DisplayCtl: (pos 'player ...) ;; DisplayCtl -> Subscribers: (at-meta (at-meta (scroll-offset ...)))
note right of DisplayCtl: Compares player pos to level size ;;
DisplayCtl -> Subscribers: (at-meta (at-meta (scroll-offset ...))) ;; ================================================================================
;;
================================================================================ ;; title Movement Sequence
;;
title Movement Sequence ;; Moveable -> Physics: (massive ID)
;; Moveable -> Physics: (attr ID ...)
Moveable -> Physics: (massive ID) ;; Moveable -> Physics: (impulse ID vec)
Moveable -> Physics: (attr ID ...) ;; note right of Physics: Processes simulation normally
Moveable -> Physics: (impulse ID vec) ;; Physics -> Subscribers: (pos ID ...)
note right of Physics: Processes simulation normally ;; Physics -> Subscribers: (vel ID ...)
Physics -> Subscribers: (pos ID ...) ;;
Physics -> Subscribers: (vel ID ...) ;; ================================================================================
;;
================================================================================ ;; title Keyboard Interpretation
;;
title Keyboard Interpretation ;; Keyboard -> Player: (press right-arrow)
;; Player -->> Physics: assert (impulse ID (vec DX 0))
Keyboard -> Player: (press right-arrow) ;;
Player -->> Physics: assert (impulse ID (vec DX 0)) ;; note right of Physics: Processes simulation normally
;;
note right of Physics: Processes simulation normally ;; Keyboard -> Player: (press left-arrow)
;; Player -->> Physics: assert (impulse ID (vec 0 0))
Keyboard -> Player: (press left-arrow) ;;
Player -->> Physics: assert (impulse ID (vec 0 0)) ;; Keyboard -> Player: (release right-arrow)
;; Player -->> Physics: assert (impulse ID (vec -DX 0))
Keyboard -> Player: (release right-arrow) ;;
Player -->> Physics: assert (impulse ID (vec -DX 0)) ;; Keyboard -> Player: (press space)
;; Player -> Physics: (jump)
Keyboard -> Player: (press space)
Player -> Physics: (jump)
|#
;;--------------------------------------------------------------------------- ;;---------------------------------------------------------------------------
;; Keyboard and Display ;; Keyboard and Display