Greeting, ye people of Haxeland!
I admit it, I'm a complete noob when it comes to Flixel, Haxe, or game development. I do have plenty of coding experience though, mostly from working on several web apps made with Javascript and PHP. Every now and then I get some game ideas that I'd like to try one day and now I've finally come up with something that I think would be a good learning project, and I've chosen Haxe and HaxeFlixel as the tools I'd like to get acquainted with.
My game is nothing fancy, a really simple fly-in-space-and-shoot-stuff kind of game, but there's one aspect I can't find too much information on that I'd be really grateful if someone would be up for exchanging some ideas on, and that's online multiplayer with an authoritative server. Let me make a list of things I think might be relevant here:
- the game is for 2 - 4 players
- there might be AI-controller entities
- physics will be involved (using Nape, though I'm not committed)
- game is in real time and rather fast-paced (but not FPS-fast-paced)
- clients should work on Win and Mac, possibly Unix, and mayhaps even mobile at some point
- server will be a Unix (Ubuntu) machine
- the possibility of cheating should be as minimized as sanely possible
- this is a learning experience so I don't mind writing bits and pieces that wouldn't maybe be mission-critical in a commercial project
The thing I'm looking to get some ideas on is how exactly to make this all work together so that neither the server nor the clients have to do too much extra work, computation-wise. I've thought about a couple of different models:
- "Dumb" clients that simply send input information to the server, which calculates everything and streams game state back to clients. This is very server-intensive and possibly not optimally responsive, but it also doesn't really leave any room for cheating.
- Each client manages their own ship, ie. the game client does all the physics calculations related to the player ship and only transmits speed / rotation / velocity / etc to the server. Server manages non-player assets, and verifies client-transmitted data. In this model I'm thinking physics would be disabled in the client for everything but the entities that particular client is managing, and their state would be streamed from the server. The server could verify the transmitted data by doing sanity checks, ie. can a player turn that fast / go at that speed / be at that location. As far as I can think of, this should be relatively cheat-proof and in general a pretty good solution.
- Each client calculates everything, and streams changes in the game state to server as they happen. Then there's always the (even likely in case of lag?) possibility of game state mismatches, where the server would have to mediate the state to be resumed from. I'm not sure if the game play would get choppy? In any case this should be really easy on the server, and should feel really responsive on the clients as well.
So, any ideas on how I should go about this? Are there some pros or cons I'm not noticing, or perhaps completely different solutions that I've missed? Is there a method that's already been battle-tested (with something created with Haxe/HaxeFlixel)?
I'd appreciate any and all input, and I'm sure helping a noob such as myself would earn a couple of extra karma points.