Skip to content

Commit

Permalink
Merge pull request #757 from phcarvalho/main
Browse files Browse the repository at this point in the history
Docs - Snake Tutorial
  • Loading branch information
aduros authored Sep 3, 2024
2 parents e357637 + f841447 commit be6bc29
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion site/docs/tutorials/snake/collision-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ What you do, is up to you. You could stop the game and show the score. Or you co
```zig
pub fn isDead(this: *@This()) bool {
const head = this.body.get(0);
for (this.body.constSlice()) |part, i| {
for (this.body.constSlice(), 0..) |part, i| {
if (i == 0) continue;
if (part.equals(head)) return true;
}
Expand Down
6 changes: 3 additions & 3 deletions site/docs/tutorials/snake/goal.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Inspiration & Goals

Snake is a simple game. You can implement it in pretty any language or engine. It also allows for real-time user interaction and is a challenging game in itself.
Snake is a simple game. You can implement it in pretty much any language or engine. It also allows for real-time user interaction and is a challenging game in itself.

## Goals

And the end of the tutorial, you will have a working version of snake.
At the end of the tutorial, you will have a working version of the game Snake.
You can expand on it and make your very own version along the way.

During this tutorial you will learn how to ...
Expand All @@ -25,4 +25,4 @@ You'll find all completed implementations in the various languages.

At the end of this tutorial, your snake game will look like this:

![Snake Preview](images/endresult.webp)
![Snake Preview](images/endresult.webp)
6 changes: 3 additions & 3 deletions site/docs/tutorials/snake/handling-user-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ But first, you need to understand how WASM-4 handles user input.

## Gamepad Basics

WASM-4 provides 4 variables that represent the current state of the respective gamepad. It's `0` (Zero) if nothing is pressed right now. Otherwise it contains a sum of those values:
WASM-4 accepts up to 4 gamepads and provides 4 variables that represent the current state of this gamepads. It contains a value `0` (zero) if nothing has been pressed; otherwise, it contains a sum of the buttons pressed, based on the table below:

| Button | Value |
|----------|:-----:|
Expand Down Expand Up @@ -421,9 +421,9 @@ impl Game {

```zig
export fn update() void {
frameCount++
frame_count += 1;
if (frameCount % 15 == 0) {
if (frame_count % 15 == 0) {
snake.update()
}
Expand Down

0 comments on commit be6bc29

Please sign in to comment.