bootcamp icon indicating copy to clipboard operation
bootcamp copied to clipboard

Errors in 06-Game

Open JeBuSBrian opened this issue 6 years ago • 3 comments

In 06-Game.md In the section: Pressing any key shall change the direction in which the player is moving

There is a missing comma after the changeDirection function.

JeBuSBrian avatar Oct 03 '19 23:10 JeBuSBrian

In the section: Increase the speed of the player

There is a typo in the player object. It says 'die' when it should say 'dir'.

JeBuSBrian avatar Oct 03 '19 23:10 JeBuSBrian

In the section: Add a scoring mechanism

The return keyword is in the wrong place. It is currently:

return {
    moveSpawns: function(){

It should be:

  return {
    player: function () {

JeBuSBrian avatar Oct 03 '19 23:10 JeBuSBrian

The snippet return { moveSpawns: function(){ is as intended. If you refer to the prior section where we add collision detection you will see we moved the moveSpawns() to within the return statement. This is because moveSpawns() needs access to player() for the sake of collision detection. When we add the scoring mechanism we are adding that on top of collision detection so moveSpawn() and player() remain in the same location and scope.

In the final section, the code is refactored such that moveSpawns() and player() are moved above the return statement. The key is that these two functions remain in the same scope. The code in it's final form exposes only two functions; init() and changeDirection(). This type of closure simulates private and public access (with some odd scope limitations) in JavaScript. Additionally, this is intended to expose my process (you will each develop your own over time) to the the student.

  1. Get something working.
  2. Think of ways to improve the code, functionality, and/or UX/UI.
  3. refactor and iterate.

I think what the documentation is missing, is a deep dive into this thought process.

jasonsnider avatar Oct 09 '19 16:10 jasonsnider