agar.io-clone icon indicating copy to clipboard operation
agar.io-clone copied to clipboard

Rewrite to ES6

Open krtr opened this issue 9 years ago • 19 comments

It would involve new code layout and some time so new branch for this task should be created in main repo. #80

krtr avatar Jun 01 '15 15:06 krtr

using Browserify was mentioned by @danprince

krtr avatar Jun 01 '15 15:06 krtr

I can split client code into something like that:

  1. Player module for Player class and CurrentPlayer class which extends Player class to add input handling
  2. PlayerList module for PlayerList class which has lists of all players maybe also similar class for food

krtr avatar Jun 01 '15 20:06 krtr

I would recommend breaking it up into:

  • Rendering module
  • Game/State module
  • Chat module
  • Events module

Rendering module is completely independent of state, just needs to know about what should be on screen at a given point.

Game/State module keeps track of data that has arrived from the socket in the events module as well as passing mouse/keyboard inputs to the server (through the events module).

Chat module just handles rendering chat messages and passing input to and from the events module.

Events module is the wrapper for all of the socket stuff. Everything else hooks into here.

Quite happy to do any of the above and pretty comfortable with ES6 too.

danprince avatar Jun 01 '15 21:06 danprince

@danprince Your way looks better than mine I'm with you :+1:

krtr avatar Jun 01 '15 21:06 krtr

Initial feelings on this as a style?

https://github.com/danprince/agar.io-clone/blob/es6/client/js/render.js

danprince avatar Jun 02 '15 08:06 danprince

@danprince Bowserify is laying in es6-refactor branch so you can pull if you want, and the code looks quite nice. :+1:

krtr avatar Jun 02 '15 11:06 krtr

Cool, nearly finished modularising + ES6ing all of the client side.

danprince avatar Jun 02 '15 11:06 danprince

Removing help wanted tag since there's already people working on that :)

igorantun avatar Jun 02 '15 18:06 igorantun

Hi, what is left to do on this branch? I did a quick test and it seemed to be working pretty good except for a bug parsing chat commands.

Again avatar Jul 03 '15 22:07 Again

Discussion continued with PR #128

danprince avatar Jul 03 '15 23:07 danprince

So are people still up for this? the es6-refactor branch looks incredibly outdated at the moment.

abalabahaha avatar Sep 04 '15 02:09 abalabahaha

yeah, if anyone is willing to dedicate some time to it. It would be nice.

keithagroves avatar Sep 04 '15 20:09 keithagroves

The day has come! I have completely refactored the site to use es6.

https://github.com/underGhost/agar.io-clone/tree/es6-refactor

What did you do?

  • Took the guts of the current site and converted to es6.
  • Refactored the code and removed 99% of linter errors (there was a lot of hoisting and methods called before being declared).

What came of it?

  • Cleaner code
  • Easier maintainability
  • Pretty es6 things
  • Helped with the games latency

What is still needed:

  • Testing - I have tested pretty much everything except player consumption.
  • Build System - I need to refactor the site to build server side.

Contributors

  • Need help with the thinks listed above.
  • If you contribute I recommend using Atom if you're not already. I use the following packages to help with linting:
    • language-babel, linter, linter-eslint

Please let feel free to contribute in any way and pull it down to give it a test!

underGhost avatar Jan 28 '16 19:01 underGhost

Wow! Awesome man! :+1:

Since we use ES6, how about using template string? https://github.com/underGhost/agar.io-clone/blob/es6-refactor/server/index.js#L63

huytd avatar Jan 28 '16 21:01 huytd

Thanks! I'll be sure to update all of them :+1:

underGhost avatar Jan 28 '16 22:01 underGhost

Updated the strings to template strings @huytd

underGhost avatar Jan 29 '16 21:01 underGhost

Great! Do you want to make a pull request to es6-refactor branch of this repo?

huytd avatar Jan 29 '16 22:01 huytd

@underGhost That looks awesome! Great job :smile:

igorantun avatar Jan 29 '16 23:01 igorantun

Thank you!

underGhost avatar Jan 30 '16 00:01 underGhost