Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some suggestions - see PR message #2

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

chomamateusz
Copy link

You can use .preventDevault to prevent window from scrolling when arrow keys are down. - > https://drive.google.com/open?id=0BxbIDtQqSCoCdk5VS0VQMkQxYXM

I see that in "keydown" event you use key codes to detect arrow keys - there is a more easy way with .key property of that event - https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
Moreover .keyCode is DEPRECATED! https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode !

I think it will be a good pratcice to group code in main.js in sections like:

  • setting initial state
  • setting liseners and load resources
  • gameplay functions
  • run code at the end ()

Also i think is a good pratcice to pas dependencies into functions by arguments not directly form global scope (line 1 and 278 of main.js).

Be careful with Object.create because it don't copy the object! It set the prototype to the old oobject so modyfications on old object have impact on new object. If you want check Object.assign https://developer.mozilla.org/pl/docs/Web/JavaScript/Referencje/Obiekty/Object/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant