Picking up an MMO project from years ago

For discussions about game development that does not fit in any of the other topics.
Post Reply
ShawnSwander
Posts: 53
Joined: Thu May 17, 2012 12:31 am

Picking up an MMO project from years ago

Post by ShawnSwander »

So last time I made an mmo I think my code got so spagetti stringged and I changed my mind so many times about how to solve my problems during the process of making it that I abandoned the game and at one point I was almost finished and hit a wall where the program just wasn't running efficiently.

So the idea behind the game is using socket.io:

- all the client does is send commands to the server
- the server processes everything and sends back instructions so the client can update the image.
- I was using impact.js and I really felt like that wasn't a great solution but I hate to reinvent the wheel.

Here are some issues I'm dealing with
- I don't want the client to use a full size level or map they can see a 7x7 grid of squares and that's all I want the server to send them.
- there isn't a good reason to keep entities that aren't on the screen.
- I'm very afraid of making my code into spagetti string that I can't come back to and figure out what I Was doing if I take a break.

So my questions are:
- Should I use impact engine? Is that still a good approach?
- I won't use weltmeister because the maps are served to the client by the server, Do I need to load levels for things like gamestate changes? I'm not familair with an elegant way to do gamestate changes last time mine just looked like switch statements and I hate that.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Picking up an MMO project from years ago

Post by hallsofvallhalla »

Impact is can be tough to get working well with Nodejs. I have some tutorials on doing it but the problem is running all the logic server side. You "classes" are defined client side so you cannot access them on the server. It becomes tricky. I basically made the server do basic logic then made calls to the client to run the impact functions.

I have moved away from impact. Mainly because if I want to open source my game later i can't, nor can I ask another developer to help me. Engines like Phaser are way ahead of Impact now. Check it out
https://phaser.io/
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Picking up an MMO project from years ago

Post by Jackolantern »

I second that. I really have no idea what happened to the author of ImpactJS. He started working on Ejecta (his iOS conversion tool) and almost completely stopped working on Impact. And I mean for a couple of years. In that time other engines (namely Phaser) got to Impact's level and then surpassed it. Impact only uses Canvas, which is a huge draw-back when you compare the performance of WebGL. Phaser also natively uses Tiled for tilemap creation. As nice as Weltmeister seems at first, it is much better to use the industry-standard tilemap editor. It also decouples your level data from the engine. You can serve tilemaps from your server easily with Tiled and Phaser since the engine loads the external level data anyway.

The only down-side to Phaser is that it doesn't enforce the kind of structure that Impact did. You have to set up your own structure to it, and that can range from all in one file (very small demo games) all the way up to highly architected solutions (definitely the better way to go for a large game like anything approaching an MMO). It does play well with Typescript or Babel, so you can use the module systems that those include as well as the other nice enhancements.
The indelible lord of tl;dr
ShawnSwander
Posts: 53
Joined: Thu May 17, 2012 12:31 am

Re: Picking up an MMO project from years ago

Post by ShawnSwander »

Thanks for the feedback. I'm really excited to pick the project up and phaser even has a state manager of some kind I felt like gamestates made my code really hard to read.

Is there a good tutorial where someone users phaser to generate the type of game that no data that goes to the server actually gets changed on the client side. I had SO many socket emit functions on my old one and I'm wondering if there is a better way like making an updatePacket class so you just emit JSON update packets that the client handles.

The way I am planning on doing this is

Player wants to fight the goblin so he double clicks it.
client sends "attack goblin" to server...
server verifies client is able to attack the goblin and performs the calculations
server pushes an "update packet" into an array.
the server goes through the array and for each event determines which players can hear or see the event.
Obviously the player who hit the goblin is among that list and the server also determines who else can see the goblin get hit and sends them the same packet
The player parses the data as "You hit the goblin for light damage"
because other clients don't match the player id they parse the same packet as playing a sound and maybe seeing the goblin's HP drop.

My attempt at the game last time was probably close to 20k lines of code it was sloppy and even had some performance issues.

I went through the phaser documentation it looks really helpful my biggest fear is I put tons of time into it and end up with spagetti string again because not many tutorials I've seen have a nice folder structure for a server which I'd like to put on a secure folder

I saw the getting started tutorial that was really good. I'd love more like that.
ShawnSwander
Posts: 53
Joined: Thu May 17, 2012 12:31 am

Re: Picking up an MMO project from years ago

Post by ShawnSwander »

quick question

Is there a way to use an array of sprites on one image instead of using hundreds of images in phaser? I'm looking at the documentation for phaser and the issue is when I type tilesets it seems to mean something different.

I think it's sprite sheet but I don't see a way to load a sprite from it.
ShawnSwander
Posts: 53
Joined: Thu May 17, 2012 12:31 am

Re: Picking up an MMO project from years ago

Post by ShawnSwander »

scratch the last question. I think I'm figuring out things the phaser website is really great I think I agree and I'm dropping impact for this.

I'm really stoked to be picking up a project for me this is kind of a bucket list thing.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Picking up an MMO project from years ago

Post by Jackolantern »

Probably the best way to handle the piles and piles of socket emit-type calls is to wrap them up into a publish-subscribe module both on the client and server side. This way, you have one actual Socket.io event registered on both the client and server, but you send as a standard part of your data a different event string. Then you can have one place on both your client and server that actually takes in all incoming socket calls and calls event handlers registered to your custom event string. You can create a module that allows you to store callback functions or promises into an object with the key being the registered custom event string. When a call comes in, if that event string exists as a key in the object, you call every function or resolve every promise, passing in the data sent from the other side with your custom event string stripped out.

Let me know if that doesn't make sense :) Because yes, Socket.io calls can get out of hand very quickly and you can have piles and piles of socket event handlers and spaghetti code trying to deal with them all. The benefits of a pub-sub module like this is that you can register the event callbacks where they make sense instead of piling all of them up in one place.
The indelible lord of tl;dr
Post Reply

Return to “General Development”