Search the Community
Showing results for tags 'headless'.
-
Hey guys. So me and my friend have been hitting the grind on network programming for the server side of our real-time multiplayer game. Our game involves handling collisions with synchronized enemies and projectile/melee-based weapons. We don't really care about player-player collisions, but it might be something we want. From what I've been understanding, for this game I'd want to have an authoritative server that essentially has a game loop running that simulates the game state. The clients will interject with their desired actions and use client-side predictions to render what they think should be happening, which will be corrected by the server on a tick-based system. Correct me if I'm wrong in thinking this is the best method to use. But assuming it's a good method, I'm unsure of how to simulate the gamestate on the server. Is it common to use a headless version of your client-side engine to simulate the state on the server? I've heard not fun things about using Phaser-headless on a server. Are we going to have to basically simulate a bare-bones version of our game in NodeJS using vanilla JavaScript? I'm skeptical of this because it feels like reinventing a fairly large wheel. Thanks.
-
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.
-
I have utility functions and lot of them are just drawing to game.add.graphics object. Some of them have rather complex behavior, like calculating some values to see if something should be drawn or not. The problem is these function can accept large number of different values so I should be testing them. An example function: drawShelve: function (dataObject) { var halfHeight = this.roundNumber((dataObject.frameHeight / 2), frnConst.BETTER_PRECISION), halfRearHeight = this.roundNumber((dataObject.rearHeight / 2), frnConst.BETTER_PRECISION), grObject = null, shelve = { graphicsObj: dataObject.graphicsObj, borderSize: constGr.DEFAULT_GRAPHICS_BORDER_SIZE, borderColor: dataObject.borderColor, borderAlpha: 1, areaColor: dataObject.areaColor, frontColor: dataObject.frontColor, thickness: dataObject.thickness, polygon: { pt1: {x: 0, y: 0}, cp1: {x: 0, y: 0}, pt2: {x: 0, y: 0}, pt3: {x: 0, y: 0}, cp2: {x: 0, y: 0}, pt4: {x: 0, y: 0}, pt5: {x: 0, y: 0} } }; // draw top corner shelves if (dataObject.shiftY >= this.roundNumber(dataObject.y + dataObject.halfCupboardDepth, frnConst.NUM_OF_FLOAT_DIGITS) && dataObject.shiftY < this.roundNumber(halfHeight + dataObject.y, frnConst.NUM_OF_FLOAT_DIGITS)) { shelve = {/* some code */}; grObject = this.drawShelveWithArea(shelve); // draw rectangle instead of full shelve when exact half is hit with a Y coordinate } else if (dataObject.shiftY === this.roundNumber(halfHeight + dataObject.y, frnConst.NUM_OF_FLOAT_DIGITS)) { grObject = /* draw rect code here */; // draw bottom corner shelves } else if (dataObject.shiftY > this.roundNumber(halfHeight + dataObject.y, frnConst.NUM_OF_FLOAT_DIGITS) && dataObject.shiftY <= this.roundNumber(dataObject.y + halfHeight + halfRearHeight, frnConst.NUM_OF_FLOAT_DIGITS)) { shelve.polygon = {/* some code here */}; grObject = this.drawShelveWithArea(shelve); } return grObject; } As you can see, there is if block and then two else-if blocks. All conditions are calculated and I must test if the shelve is drawn or not for different values, i.e not null. I set QUnit and added game object where can i draw with HEADLESS mode, but from the following picture I still see canvas added to my test page. How can i test without adding game object at all? Is it possible to utilize functions like: shelveWithArea.beginFill(dataObject.areaColor, 1); shelveWithArea.moveTo(polygon.pt3.x, polygon.pt3.y); shelveWithArea.bezierCurveTo(polygon.pt3.x, polygon.pt3.y, polygon.cp2.x, polygon.cp2.y, polygon.pt4.x, polygon.pt4.y); shelveWithArea.lineTo(polygon.pt5.x, polygon.pt5.y); shelveWithArea.lineTo(polygon.pt3.x, polygon.pt3.y); shelveWithArea.endFill(); Without a need of Phaser.Game object?