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

fix up JS snake game instructions #624

Merged
merged 1 commit into from
Feb 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/site_extensions/javascript-snake-game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def js_expected_results(lesson)

source_code :js, File.read(src_path)

h4 'How the game should work:'
h4 'How the game should work so far:'

canvas id: 'chunk-game', height: '600', width: '800'

Expand Down
19 changes: 18 additions & 1 deletion sites/en/javascript-snake-game/lesson-2.step
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,26 @@ js_expected_results 'lesson-2'
MARKDOWN
end

step "Comments" do
markdown <<-MARKDOWN
Sometimes it's nice to leave a clarifying note to future readers of the code (this could very well be you!) in plain English. This is called a comment, and it is only intended for humans to read, the computer knows to ignore them.
Here's what comments look like in JavaScript:

```js
// this is a one line comment, here we're creating an array
var drawableObjects = [drawableSnake];
/*
this is a multi line comment
here we're drawing the snake
*/
CHUNK.draw(drawableObjects);
```
MARKDOWN
end

step "Play Time!" do
markdown <<-MARKDOWN
* Add comments underneath each line explaining what it does in plain old english.
* Add comments above each line explaining what it does in plain old english.
* Change the color of the snake.
* Make the snake longer than just 1 segment!
* Draw something in addition to the snake. Perhaps an apple or a wall? Make
Expand Down
19 changes: 19 additions & 0 deletions sites/en/javascript-snake-game/lesson-6.step
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ MARKDOWN
js_expected_results 'lesson-6'

markdown <<-MARKDOWN
### Switch statement

A `switch` statement is another way to organize a seried of `if` and `else if`s. Here's an example:

```js
switch(color) {
case "red":
return { action: "stop" };
case "orange":
return { action: "wait" };
case "green":
return { action: "go" };
default:
return { action: "unknown" };
}
```

Can you figure out how to replace our snake game code above with a `switch` statement? (Don't worry, you'll see how we do it in the next lesson)

### Play Time!

* Use a switch statement instead of a series of ifs
Expand Down