realtime-multiplayer-in-html5
realtime-multiplayer-in-html5 copied to clipboard
Extract all logic that is not game specific from ClientGame.js
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
:
-
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. -
Abstract Client Methods: these would be moved to
AbstractClientGame
and called byCustomClientGame.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 callAbstractClientGame.updateInput(inputData)
which would callnetwork.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:
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.