MCPcopy Create free account
hub / github.com/codemistic/Web-Development / update

Function update

Snake Game /snake.js:7–17  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5let newSegments = 0
6
7export function update() {
8 addSegments()
9
10 const inputDirection = getInputDirection()
11 for (let i = snakeBody.length - 2; i >= 0; i--) {
12 snakeBody[i + 1] = { ...snakeBody[i] }
13 }
14
15 snakeBody[0].x += inputDirection.x
16 snakeBody[0].y += inputDirection.y
17}
18
19export function draw(gameBoard) {
20 snakeBody.forEach(segment => {

Callers

nothing calls this directly

Calls 2

getInputDirectionFunction · 0.90
addSegmentsFunction · 0.85

Tested by

no test coverage detected