Skip to content

63r6o/frp-pacman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

functional reactive 1D pacman pacman

A 1D pacman game, inspired by paku paku, implimented with a subset of RxJS, roughly equivalent to Conal Elliott's original FRP formulation.

The game's state is calculated as a pure function of time (animationFrames) and space presses, with the only side-effect being the actual drawing of the canvas.

image

The shape of the game's state:

{
    playerX: number,
    ghostX: number,
    dots: { x: number, magic: boolean, eaten: boolean }[],
    isMagicOn: boolean,
    isBlinking: boolean,
    score: number,

    isGameOver: boolean,
    text: string
  }

The game is hosted at https://63r6o.github.io/frp-pacman/.

Installation

If you'd like to run it locally, clone the repository, npm install the dependencies then run the dev server with npm run server.

Structure

└── src/
    ├── index.html      // the html page with the canvas
    ├── index.js        // the observable streams calculating the state of the game
    ├── rxjssubset.js   // the "white-listed" functions of RxJS
    └── utils.js        // functions related to position calculations and drawing

Releases

No releases published

Packages

No packages published