Game Development Reference
In-Depth Information
fruit.reset();
snake.grow();
score.up();
}
renderTime.last = renderTime.now;
}
}
// Render everything: clear the screen,
draw the fruit, draw the snake,
// and register the callback with rAF
renderer.clear();
renderer.draw(fruit.position, fruit.img);
renderer.draw(snake.getBody(),
snake.getSkin());
requestAnimationFrame(gameLoop);
}
// If the snake is dead, stop rendering and
disable
// the key handlers that controlled the snake
else {
document.body.removeEventListener("keydown",
snake.doOnKeyDown);
}
}
Search WWH ::




Custom Search