microtrain / bootcamp

Courseware for MicroTrain's Dev Bootcamp
17 stars 39 forks source link

Errors in 06-Game #2

Open JeBuSBrian opened 5 years ago

JeBuSBrian commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 () {
jasonsnider commented 5 years ago

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.