Skip to content

Commit

Permalink
Adds conclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
drakeltheryuujin committed Nov 16, 2018
1 parent 686c7d1 commit e6a241c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function moveDodgerLeft() {
```

We're doing essentially the same as above, but we first ensure that the dodger's left edge has not
xgone past the left edge of its container. (Remember, position is relative to the container.)
gone past the left edge of its container. (Remember, position is relative to the container.)

Let's wire this up

Expand All @@ -172,17 +172,19 @@ document.addEventListener('keydown', function(e) {

Now try moving the dodger past the left edge. No can do!


While this isn't tested, and this was meant as a code-along, we have not yet implemented moving
the dodger to the right. Can you do it?

Think about what needs to change to make a `moveDodgerRight()` function. We'll need another
`e.which` in the event listener, and instead of moving the dodger `${left - 1}px`, we'll be moving
it `${left + 1}px` (or `${right - 1}px`, if you prefer). To prevent the dodger from escaping off
We have not yet implemented moving the dodger to the right. Can you do it? With the code implemented
from the code along, think about what needs to change to make a `moveDodgerRight()` function. We'll
need another `e.which` in the event listener, and instead of moving the dodger `${left - 1}px`, we'll
be moving it `${left + 1}px` (or `${right - 1}px`, if you prefer). To prevent the dodger from escaping off
the right-hand side, you can make sure that `dodger.style.right` is always greater than `0px`.

## Conclusion

Events and event handling is vital to web programming with the addition of the language to browsers.
JavaScript allows for dynamic page rendering, and user can interact with the contents of the page
in real time. With knowledge of these basic techniques, you'll become comfortable working with more
complex interactions like those in video games that you may have played or seen before!

## Resources
- [Don't Look Back](http://terrycavanaghgames.com/dontlookback/)
- [Braid](http://braid-game.com/)
2 changes: 1 addition & 1 deletion test/indexTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ describe('moveDodgerRight', () => {

expect(newPosition).to.be.above(left)
})
})
})

0 comments on commit e6a241c

Please sign in to comment.