Search the Community
Showing results for tags 'jsdom'.
Found 1 result
Hello All, I am working on a multiplayer action role playing game and I am using Phaser on the client because I just love this framework. Here is a link to the project on GitHub: https://github.com/crisu83/dungeon-game/tree/feature/phaser-server I have been experimenting quite a lot with running Phaser in headless mode on the server and I managed to get it to run with a few hacks. I am not sure that it is a good idea to run Phaser on the server, but I am looking into this because I would prefer to have an authoritative server that runs on the same code base as my clients. Here is what I did in order to get Phaser running on the server: First I installed the latest stable version of Phaser through NPM by running the following command: npm install http://github.com/photonstorm/phaser/tarball/v2.0.5After that I installed the dependencies for Node Canvas, instructions for that can be found in the project wiki on GitHub: https://github.com/LearnBoost/node-canvas/wiki Next I installed node-canvas and jsdom through NPM. These modules are required in order to "fake" the document, window, canvas and image objects that Phaser depends on that all are available in all browsers, but not on Node.js. npm install jsdomnpm install node-canvasThen I wrote this wrapped module for Phaser: https://gist.github.com/crisu83/5857c4a638e57308be4f I know that this is a ugly hack, but it at least lets me run Phaser on the server. Here is what the server currently outputs: I am now wondering if I should attempt to make changes to Phaser itself to not rely on the document, window, canvas, image when running in headless mode and create a pull-request for the changes. I am sure it will not be easy to remove all those dependencies, if even possible. Does anyone know if Richard has any plans for this? Does this even make sense to run Phaser on the server? Please share your ideas and feel free to use my code for your own projects. Thank you for reading.