Ricky-N / base-game

Basic multiplayer game developer setup for Isogenic Game Engine with static servers, dev process automation, and some common game models
0 stars 0 forks source link

More than one Map? #1

Closed dfsdfsdfs closed 8 years ago

dfsdfsdfs commented 8 years ago

I was searching for ige sample projects and found this one. I was wondering if there's a way to make multiple maps?

After reading these two threads (http://www.isogenicengine.com/forum/viewtopic.php?f=8&t=73&hilit=stream & http://www.isogenicengine.com/forum/viewtopic.php?f=8&t=526&p=1687&hilit=stream#p1687 ) and trying out different combinations for ten hours I haven't been able to spawn two clients in two different maps.

Forum of the engine is dead. I don't know if this engine is supposed to use only a single tiled map. Every approach I found is broken.

Ricky-N commented 8 years ago

I haven't been able to get a forum account either :/. I haven't had to implement rooms yet for my purposes, but I know I will so I decided to try it out. So the second link you posted is not really useful, actually from my experience I think its a pretty bad way to stream data down.

I'd be willing to bet you are hitting the same things that I just got hung up on:

  1. On the server you need multiple viewports, each mounted to ige and watching your "room" or whatever you want to call the main scene for each map.
  2. On the client, you need a single viewport, but the ids for the viewports and scenes need to match the ones for the room you want to be in or the stream system won't be able to find the right things to update.

From there, it is basically just as he said in his post, he just neglected to talk about creating another viewport so that the update method for the scene would actually get called on the server, leading to the room being streamed and all the entities created.

Check out this gist: https://gist.github.com/Ricky-N/870f48c383961686a014

As it says there, you should just have to replace the appropriate files in your 24.4-multiplayer-isometric-keyboard example with those ones to get what I hacked together to work. It is in no way clean or anything good at all, but it is a working starting point.

dfsdfsdfs commented 8 years ago

Your bet was right. The gist didn't work, tho. Would you mind answering three basic questions? 1 - Why is your structure (ie "ClientNetworkEvents" with no more "_onPlayer[...]") better than the example structure? Any benefits performance wise? 2 - Why your code runs new "ServerNetworkMessage('playerEntity')" but totally ignores "ServerNetworkMessage('connect/disconnect')? 3 - Any benefits of going through confusing mainscenes, secondaryscenes, tertiaryscenes, in comparison with running phaser + multiroom socket.io? I'm unsure about using this engine because I still don't see the advantage over other tools. Is the network handling really that good?

Ricky-N commented 8 years ago

Sure thing,

  1. I tried to keep things as modular as possible, that's a pretty big principle of software engineering to enable scaling from a few hundred lines of code to arbitrarily large code sizes. I didn't want my server module to have to know about every single event that happens in the network, because it has to manage a lot of other startup features already. This is related to something called the Single Responsibility Principle. I work in a large software company, and having looked through the example projects I can 100% say that they were not built with the intention of creating a scalable game out of them, but purely to show how to use the features. That's how it should be, otherwise it would be a nuisance, but is part of the reason I set up this project, just to give a start to people who actually want to create a game, have a build system, etc. I started pushing code a while back to my private repo so there is still quite a bit to be done here, but it at least puts some pieces together.
  2. This one is mostly for load order, basically connect / disconnect is just when they first hop / leave the socket and would be most useful for login / logoff purposes. I think they are pretty good places to deal with persistent storage as well. The thing is even though the client is connected, you may not want to spawn their player entity immediately as there will probably be a ton of initialization that needs to happen. Not all of it can be done before the connection and you may want to wait until you are sure they can connect anyways to have smoother error handling. That is why it is useful for them to tell you when they are done with initialization and should have a character spawned for them. This one is totally dependent on your game though and what you want your init to look like.
  3. The code I hacked together is not an extensible way to create multiple maps, if I were to do it I would definitely do it differently, so I think with clean code it wouldn't be too bad. I've built out initial games using Phaser + Socket, Pixi + Socket, and this and I have really been impressed with this engine. I'm actually a bit surprised they decided to open source it, as it has a lot to it, but its hard to make money off of something like this. There are some problems, but I think it is worth using their engine over trying to build your own. You will very very likely end up having to build out most of the same features, and I was honestly shocked by how easy some things were with this engine. For instance, when I wanted to turn on object collision / detection I actually just added about 5 lines of code to my whole project and had it working very well.

Sorry if that's a bit long winded, let me know if you have any other questions.

dfsdfsdfs commented 8 years ago

Would you mind showing me a working example of two players mounted to two different maps and not streaming data to each other? I'm starting to think the engine is bugged. https://gist.github.com/dfsdfsdfs/7fa11d8b9f4eee1c305d Good luck. If you are able to tell me what's going on (It's not me I swear!!) I may help you with your game. Say one functionality and I will make it for you.

Ricky-N commented 8 years ago

I played around with the camera on my gist example some more (I had just disabled camera following), it looks an awful lot like there is a bug in the engine. I am hesitant to say that though, it is much more likely that we missed another configuration, but I'll try to look into it some more when I get home.

dfsdfsdfs commented 8 years ago

Thanks a lot, man. The editor "ige.addComponent(IgeEditorComponent)" doesn't work either. You can do some stuff on the browser but you can't save or export it. https://gist.github.com/Solib/7833156 This gist works as in loading two maps and stream only to entities inside them (you can check this by opening a few browsers, in the console you will read that a new entity appeared only if they are mounted to the same map). It fails to mount the player characters tho.