I'm working on a puzzle game in Flash. It's a two-player, head-to-head game with some realtime elements. It is not Tetris-like, but the level of player interaction and the rate of movement is similar to, though slightly more complex than, Tetris Battle on Facebook.

Naturally, I would like to match players up over the Internet. I would also like to prevent cheating as much as possible. Because of this, I am researching an authoritative server solution, much like Colin Moock describes in this answer to a similar question. That is, the server runs the authoritative game logic while the client runs a parallel simulation, sending player movements to the server for validation.

My question is this: Doesn't this essentially mean implementing the game logic on both the client and server side? Worse still, the server probably isn't going to run its simulation in Flash/ActionScript, which means you can't share code and you'll be implementing the same logic twice in two different languages. This sounds like a logistical, bug-riddled nightmare. Am I misunderstanding the problem?

有帮助吗?

解决方案

Having worked at several companies that make Flash games/apps of this type, I can tell you that I haven't come across a solution to this. If you want safety, everything needs to be evaluated server-side, and if you want responsiveness, your client needs to be able to handle things while calls are going out to the server. Welcome to the exciting world of client-server communications.

That being said, AS3 code is extremely similar to Java, especially if you've properly separated your business logic from your view. This makes writing a Java server super easy (we trained several Flash developers to write server logic in a manner of days, but writing the complete server takes some time). Also, you might have luck searching for an Actionscript to Java converter (though everything I've seen requires some manual correction afterward).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top