Skip to content

Commit d671030

Browse files
committed
fix: Link to conditionals-and-interactivity
1 parent ad1c29f commit d671030

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/content/tutorials/en/responding-to-inputs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ function checkSelf() {
382382
- It sets the initial direction to the right  with `snake.xSpeed = 1` and `snake.ySpeed = 0`
383383
- It creates an empty array to manage the snake’s body, creates a head segment with the current position, and adds it to the body array.
384384

385-
The `checkEdges()` function uses [if-statements](/reference/p5/if-else) to check if the snake has reached the right edge (`cols`), if the snake has reached the left edge (`-1`), if the snake has reached the top edge (`-1`), and if the snake has reached the bottom edge (`rows`). Whenever any of the conditions are met, it sets `gameOver` to `true`. This creates the rule in the game where if the snake reaches any edge, the game is over. The `moveSnake()` function updates the snake’s position based on its current speed. It updates the x and y positions by adding its `xSpeed` and `ySpeed`, respectively. Refer to the [Conditions and Interactivity](/tutorials/conditions-and-interactivity) tutorial to review the syntax for if-statements and updating variables.
385+
The `checkEdges()` function uses [if-statements](/reference/p5/if-else) to check if the snake has reached the right edge (`cols`), if the snake has reached the left edge (`-1`), if the snake has reached the top edge (`-1`), and if the snake has reached the bottom edge (`rows`). Whenever any of the conditions are met, it sets `gameOver` to `true`. This creates the rule in the game where if the snake reaches any edge, the game is over. The `moveSnake()` function updates the snake’s position based on its current speed. It updates the x and y positions by adding its `xSpeed` and `ySpeed`, respectively. Refer to the [Conditions and Interactivity](/tutorials/conditionals-and-interactivity/) tutorial to review the syntax for if-statements and updating variables.
386386

387387
- The `updateBody()` function updates the positions of the snake’s body segments. It does this by iterating through the snake `body` array starting from the end, updating each body segment’s position to match the position of the segment in front of it. Then it updates the head’s position to the snake’s current position. Refer to the [Repeating with Loops](/tutorials/repeating-with-loops) tutorial to review the syntax for loops and iteration.
388388
- The `drawSnake()` function renders the snake on the canvas. It sets the color to green, iterates through each body segment, and draws a square on the canvas at its position.

0 commit comments

Comments
 (0)