Skip to content

lucamug/functional-pacman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Functional Pac-Man

Animation

An interpretation of the Pac-Man game, written in approximately 1K lines of purely functional code. It runs both in the browser and in the terminal.

The game is written in the Elm language and the Gren language, using the TUI library for the version that runs in the terminal.

To run the game in the browser

Go to: https://lucamug.github.io/functional-pacman/

To run the game in the terminal

Execute:

git clone https://github.com/lucamug/functional-pacman/
cd functional-pacman
node docs/gren-pacman

The program requires Node.js v20 or later.

Debug modality

By pressing [B], you can display additional internal information on the side of the playing area.

Screen 2

Development

Clone the repository:

git clone https://github.com/lucamug/functional-pacman/
cd functional-pacman
npm install

Several commands are available in the cmd folder.

To work on the Elm code

cmd/start-elm

Then point your browser to http://localhost:8003/.

The main file is Game.elm. This code is the same as Game.gren. They are kept in sync via a symlink. After editing any Elm file, the game in the browser will automatically hot-reload.

To work on the Gren code

cmd/start-gren

This will compile and run the code in the terminal. [ESC] or [CTRL + C] to exit.

To format the Gren code

cmd/format-gren

To release a new version

Run

cmd/build

This will update the file in /docs/. These files can be published via Github from "Settings > Pages > Deploy from a branch > main /docs".