All Projects → Jerenaux → Phaserquest

Jerenaux / Phaserquest

Licence: mit
Reproduction of Mozilla's BrowserQuest using Phaser, socket.io and Node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Phaserquest

Tap Tap Adventure
Tap Tap Adventure is a massively online 2D MMORPG set in the medieval times with twists.
Stars: ✭ 123 (-60.7%)
Mutual labels:  game, socket-io, html5
Phaser3 Docs
Phaser 3 Documentation and TypeScript Defs
Stars: ✭ 339 (+8.31%)
Mutual labels:  game, phaser, html5
Classic Pool Game
Classic 8 Ball pool game written in JavaScript
Stars: ✭ 177 (-43.45%)
Mutual labels:  game, html5
Expo Phaser
Build awesome 2D games with Phaser.js and Expo
Stars: ✭ 182 (-41.85%)
Mutual labels:  game, phaser
Deck Of Cards
Deck of Cards (old version)
Stars: ✭ 2,684 (+757.51%)
Mutual labels:  game, html5
Allure
Allure of the Stars is a near-future Sci-Fi roguelike and tactical squad combat game written in Haskell; please offer feedback, e.g., after trying out the web frontend version at
Stars: ✭ 149 (-52.4%)
Mutual labels:  game, html5
Codenames
Stars: ✭ 159 (-49.2%)
Mutual labels:  game, socket-io
One Html Page Challenge
Can you create something cool without modern tools?
Stars: ✭ 205 (-34.5%)
Mutual labels:  game, html5
ts-phaser-bomb-game
Bomberman clone using websockets and phaser 3
Stars: ✭ 18 (-94.25%)
Mutual labels:  phaser, socket-io
blocker
🎮 (WIP - phase 3) Multiplayer online game using Phaser + WebSocket (Socket.IO)
Stars: ✭ 48 (-84.66%)
Mutual labels:  phaser, socket-io
Cavemen-GGJ2019
A multiplayer survival game developed during Global Game Jam 2019.
Stars: ✭ 21 (-93.29%)
Mutual labels:  phaser, socket-io
Kaetram Open
An open-source 2D HTML5 adventure based off BrowserQuest (BQ).
Stars: ✭ 138 (-55.91%)
Mutual labels:  game, html5
Phaser3 Particle Editor
A flexible editor for building phaser particles.
Stars: ✭ 131 (-58.15%)
Mutual labels:  game, phaser
Stage.js
2D HTML5 rendering and layout engine for game development
Stars: ✭ 2,138 (+583.07%)
Mutual labels:  game, html5
Reldens
Reldens - You can make it - Open Source MMORPG Platform
Stars: ✭ 130 (-58.47%)
Mutual labels:  game, phaser
Haxegon
A haxe programming library for beginners. Powered by OpenFL and Starling.
Stars: ✭ 182 (-41.85%)
Mutual labels:  game, html5
Example .io Game
An example multiplayer (.io) web game.
Stars: ✭ 260 (-16.93%)
Mutual labels:  game, socket-io
Caveexpress
CaveExpress is a classic 2D platformer with physics-based gameplay and dozens of levels. CavePacker is a Sokoban game.
Stars: ✭ 111 (-64.54%)
Mutual labels:  game, html5
Hilo3d
Hilo3d, a WebGL Rendering Engine.
Stars: ✭ 123 (-60.7%)
Mutual labels:  game, html5
Gdevelop
🎮 GDevelop is an open-source, cross-platform game engine designed to be used by everyone.
Stars: ✭ 3,221 (+929.07%)
Mutual labels:  game, html5

phaserquest

Phaser Quest is a reproduction of Mozilla's Browserquest using the following tools:

🔥 If you are interested in this project, you may also be interested in Westward, an open source Javascript MMORPG that I am working on! 🚀

Quick tour of the code

Client

The game canvas and the game states are created in js/client/main.js. The Home state is started first, and will display the home page of the game. The Game state is started upon calling startGame() from the Home state.

js/client/game.js contains the Game object, which corresponds to the Game state and contains the bulk of the client code. Game.init() is automatically called first by Phaser, to initialize a few variables. Game.preload() is then called, to load the assets that haven't been loaded in the Home state. When all assets are loaded, Phaser calls Game.create() where the basics of the game are set up. At the end of Game.create(), a call is made to Client.requestData() (from js/client/client.js) to request initialization data from the server. Upon reception of this data, Game.initWorld() is called, which finishes starting the game. The main update loop of the client is Game.update().

Server and updates

server.js is the Node.js server that supports the game. Most of the server-side game logic however is located in js/server/GameServer.js. Every 200ms, GameServer.updatePlayers() is called, and sends updates to all clients (if there are updates to send, as determined by the custom interest management system). Client-side, these updates are processed by Game.updateWorld() and Game.updateSelf().

The code used for the custom binary protocol for the exchange of update packets can be found in js/client/Decoder.js, js/server/Encoder.js and js/CODec.js.

Installing and running the game

For the client, everything is included in the code (phaser.js, easystar.min.js, ...). You will need npm to install the Node.js packages required for the server. To run the server, you'll need to have Node.js installed, as well as MongoDB.

Clone the repository. Inside the newly created directory, run npm install to install the Node.js packages listed in package.json. Make sure that you have MongoDB running, then run node server.js to start the game server. By default, it'll listen to connections on port 8081; you can change that behaviour by using the -p flag (e.g. node server.js -p 80). By default, it'll attempt to connect to MongoDB on port 27017; you can change that behaviour by using the --mongoPort flag (e.g. node server.js --mongoPort 25000).

Here you will find a step-by-step guide how to run and manage the application locally.

Using Docker

Alternatively, you can use the Dockerfile to create a container with all the necessary components already installed (thanks to Martin kramer for the corresponding pull request). You need to have Docker installed. Then, in the directory where you clones the project, run:

docker-compose build
docker-compose up -d

The default por when using the Docker way is 80, so you need to navigate to <IP_of_your_Docker_machine>:80 to be able to access the game (e.g. 192.168.99.100:80).

Modifying the map

In assets/maps/, you can find phaserquest_map.tmx, which is the Tiled file of the map of the game, to be edited with the Tiled Map Editor. One you have made modifications in the Tiled file, you need to export it as a JSON file. But that file will contain a lot of layers, a legacy from how the original Browserquest map was designed. A lot of layers will translate to a very poor performance with Phaser, which is a shame since most of these layers contain only a few tiles. The solution is to "flatten" them to cram as many tiles as possible in the same layers. You can do so by running formatMap() from js/server/format.js. It will look for a map.json file in assets/maps and output two new files, the flattened map files for the client and the server.

Note: It is recommended to use Tiled in version 1.1.6 or lower, which can be found here:

Map JSON format has changed in Tiled in higher versions. Cause of that provided tmx map won't be exported to JSON format supported by format.js script.

Further documentation

I have written and will keep writing articles about some development aspects of the game. The full list of existing articles is available here.

Here is the detail of the topics covered so far:

Donate

If you want to support me to make more open-source projects like Phaser Quest, consider having a look at my donation page. In particular, take a minute to have a look at my Patreon page, where you can find a listing of rewards for various levels of recurring contributions!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].