To make the code a bit easier to work with, here's a couple of suggestions for refactoring:
[ ] Avoid duplicating logic for each paddle. This will make it easier to add new paddles in the future (like left and right positioned paddles).
[ ] Avoid two separate html files for each controller. The server should ideally just create a new controller page for each player joining the game.
[x] Avoid references to local game variable in preload, create and update functions. Replace them with this. This should make it easier to break game.js a part into several files so that it is easier to work with.
To make the code a bit easier to work with, here's a couple of suggestions for refactoring:
left
andright
positioned paddles).game
variable inpreload
,create
andupdate
functions. Replace them withthis
. This should make it easier to breakgame.js
a part into several files so that it is easier to work with.