realtime-multiplayer-in-html5 icon indicating copy to clipboard operation
realtime-multiplayer-in-html5 copied to clipboard

Extract all logic that is not game specific from ClientGame.js

Open jgamedev opened this issue 8 years ago • 1 comments

ClientGame.js is currently mostly a dump for everything that the client should do and it includes helper functions such as lerp and interpolate , network functionality and game logic in the same file.

I can see at least 2 different concerns which should be abstracted out of the ClientGame.js:

  1. Helper Methods: this includes functions like interpolate(), lerp() etc. I think the usage of those should be optional because I may be using a client game library which most probably already provides this functionality for me.

  2. Abstract Client Methods: these would be moved to AbstractClientGame and called by CustomClientGame.js. This would serve to abstract the interface with the engine so it would include things like all the network layer code . For instance: CustomClientGame.updateInput() would have my custom game logic to process game inputs because this changes on evry game. After the custom code is done, CustomGame.updateInput() would call AbstractClientGame.updateInput(inputData) which would call network.sendData(inputData), thus the game logic doesn't need to know how to interface with the network layer

I will provide more suggestions on what could be extracted when I have a better understanding of the code but I'm having a hard time figuring out how it all works.

I apologize for the long post, thanks for reading!! :smiley:

jgamedev avatar Jul 03 '16 15:07 jgamedev

Thanks for the suggestions :smile: . I was going to start with issue #2 you posted. I'll probably do some refactoring and take these thing into consideration.

arjanfrans avatar Jul 03 '16 15:07 arjanfrans