A gymnasiearbete (thesis of upper secondary education) about recreating Scrabble with network support.
- Click on the green 'Clone or download' button and choose download zip.
- Extract the folder
- Install ruby
- Go to the folder in the command prompt
- In the command prompt, run
gem install bundler
- Run
bundle install
- Run
rake run
- Open the browser and go to
localhost:9292/play
- Enjoy the game!
If the error Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
is encountered, run gem uninstall eventmachine
followed by gem install eventmachine --platform ruby
.
We are done! Well, it's working as intended at least. There are some rough edges but we are happy with it! Websockets are implemented, the frontend works nicely and the backend follows the rules as it's supposed to do.
The game uses websockets for communicating between the clients and the server. The server gives data to the client when asked and updates all players when the game updates. This is not something you can do without websockets unless you continuously poll the server for updates.
The libraries used for it are sinatra and sinatra-websocket. Thanks for making them!
The UI is the browser. The main game is displayed on a canvas object using the library p5.js. The client receives a JSON file with all the information and will display it to the user. The browser handles everything until the player finishes their turn. Then the browser sends an update to the web server. The browser is easy to work with when it comes to network functionality because it is such an integral part of it. It also has native JavaScript support which makes it very easy to manipulate the browser which is exactly what we want. Another bonus is that the game can be run by practically everyone on any computer.