Skip to content

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.

2 participants