Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

multipac

multiplayer pacman

Subscribe to updates I use multipac


Statistics on multipac

Number of watchers on Github 26
Number of open issues 9
Average time to close an issue 6 days
Main language PureScript
Open pull requests 0+
Closed pull requests 0+
Last commit almost 2 years ago
Repo Created over 4 years ago
Repo Last Updated over 1 year ago
Size 233 KB
Homepage http://mpac.herok...
Organization / Authorhdgarrood
Contributors1
Page Updated
Do you use multipac? Leave a review!
View open issues (9)
View multipac activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating multipac for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

multipac

multipac is a multiplayer version of pacman. Since it's featured on the http://purescript.org website, I recently decided it would be nice to tidy it up and document it a bit, so that it can be used as a learning resource too.

Play

An instance of the game is live at https://mpac.herokuapp.com/.

Overview

multipac has examples of many useful PureScript patterns:

  • The server and the client are both written in PureScript. The server is built on purescript-node-http, and the server and clients exchange data types using the Generic instance deriving mechanism together with purescript-foreign-generic in order to exchange data as JSON with minimal boilerplate.
  • The project is built using Pulp together with npm scripts. The package.json file contains scripts to build the server and the client parts of the game.
  • Some parts of the code, particularly the Game module, make use of lenses (from purescript-profunctor-lenses) in order to make deeply nested updates easy.
  • The clients communicate with the server using HTML5 WebSockets. The clients use the purescript-websocket-simple library, while the server uses a JavaScript WebSocket server implementation from npm, namely, websocket.
  • The game-stepping function uses monad transformers from purescript-transformers: the StateT transfomer, which holds information about all the objects in the current game, as well as a WriterT transformer, which accumulates information about all the changes which were made to the game. The WriterT is used so that all of the changes which occur in each game step can be sent to each of the clients, so that they can update their versions of the game.

If you want to browse the source code, here are some pointers:

  • The Types module is perhaps the most important module. It contains type declarations and a few basic functions for all of the types involved, in particular, types for games, players, game items, messages sent between the server and clients, and so on. Most of the other modules import Types.
  • The Game module contains the bulk of the game logic, exporting functions such as stepGame, which advances the game by one step, returning a new game and a list of things that changed.
  • The Rendering module is for functions which draw a game onto an HTML canvas element.
  • BaseServer contains a basic HTTP server which deliberately has no knowledge of multipac specifically, and could potentially be useful for implementing any similar multiplayer HTML5 game. Server, which is the entry point module for the server part, builds on BaseServer. Likewise, BaseClient deliberately has no knowledge of multipac specifically, and Client, the client entry point module, builds on BaseClient.

Note that not everything in here is perfect! I'm sure there are lots of places that could benefit from a little bit of refactoring. Please feel free to ask if anything seems weird — I would like this project to function as a good learning resource as well as a fun experiment.

Required compiler version

If you want to compile multipac, it currently requires the master version of the PureScript compiler, because of a bug in Generic instance deriving. At the time of writing, the most recent version, 0.8.0-rc1, is affected by this bug. Any later releases will most probably contain the fix.

multipac open issues Ask a question     (View All Issues)
  • over 3 years Make it more suitable as a learning resource
  • over 4 years Hangs at the beginning of the countdown on Heroku free tier.
  • over 4 years Better UI if websocket connection takes a long time to be established
  • over 4 years Better UI when kicked for being idle
  • over 4 years Small screen support
  • over 4 years touch screen support
  • over 4 years Disallow eating a particular player twice in one rampage
  • over 4 years Explanation of rules
  • over 4 years Better UI when there are no open slots
multipac list of languages used
Other projects in PureScript