The WFC2D Multiplayer Techdemo project is an exam project developed for the study of procedural map generation using the Wave Function Collapse and the implementation of WebSocket technology to support online multiplayer gameplay.
Before getting started, make sure you meet the following requirements:
- Node.js
- npm (Node Package Manager)
You can follow this guide to install them
Follow these steps to install the project:
-
Clone the repository:
git clone https://github.com/AndreaMoschetto/wfc2d-multiplayer-techdemo.git
-
Navigate to the project directory:
cd wfc2d-multiplayer-techdemo
-
Run the following command to install dependencies:
npm install
To run the project on your local machine, follow these steps:
-
Ensure you are in the project directory.
-
Run the following command to build the client and start the server:
npm start
-
Open your web browser and go to
http://localhost:7777
to start playing.
The project is ready to run and fully configured, you can ignore this section if you want to try imediatelly this techdemo,
but you can customize its behavior. You can modify the configuration settings by editing the configs.yml
file.
users
: The maximum number of usersusers_per_room
: The maximum number of users per roomrooms
: The maximum number of roomstile_width
: The width of the tile*tile_height
: The height of the tile*
rooms_log
: Set totrue
to enable detailed room logging for debugging.
*We're gonna talk about these tile resolution settings in the next subsection
Yes, if you want you can customize the design of the map generated by the WFC algorithm. The things you've to do are below:
- Put your favourite tilemap in the main folder of the project calling it
tilemap.png
, like the default one - Set the
tile_width
andtile_height
configurations matching your tiles resolution - Adjust the
adjacency_roles.json
file matching your tile's adjacency roles
It's easier than it looks:
Every tile has an id representing its coordinates in the tilemap.png
file:
id: 1_2 means that it is positioned in the 3rd column of the 2nd row.
The adjacency_roles.json
file contains a dictionary where:
keys: are the id of each tile;
values are composed like so:
adjacency
: a list of 4 sublists, one for each direction up, right, down, left (in this order). Every direction sublist contains all the ids of the tiles which are allowed to be connected on that side of the entry tilesolid
: a boolean flag, if a tile is solid it's not walkable (it's a wall)
that's it! 😉
Feel free to adjust these settings to try different configurations, increase room limits or load your tileset. Make sure to save your changes before restarting the project.
If you wish to contribute to this project, you can follow these steps:
-
Fork the repository on GitHub.
-
Clone your fork to your local machine.
-
Create a branch for your contribution:
git checkout -b your-branch-name
-
Make the necessary changes and work.
-
Commit your changes:
git commit -m "Description of your contribution"
-
Push your changes to your fork:
git push origin your-branch-name
-
Create a Pull Request on the original repository.
This project is licensed under the MIT - see the LICENSE file for details or click the badge on top of the page
Thanks to Pixel Frog for creating Sensational assets