Coding Snake in JavaScript Complete Tutorial Every Step Explained with HTML5 Canvas

Опубликовано: 23 Октябрь 2020
на канале: Coding With Adam
71,272
1.5k

In this tutorial we will be creating the game snake using JavaScript and HTM5 Canvas. We will explore the game loop, collision detection, taking keyboard input and adding sound. If you enjoy this tutorial please subscribe like and share!

If you haven’t played snake let me give you the breakdown of this version of snake. You the player move around a line aka the snake as you eat various items your snake body gets longer. The objective is to keep eating the red dot and avoid hitting your own snake body or the edges of the screen if you do it’s game over. It’s your basic last as long as you can game and get the highest score using your quick reflexes.

Through this tutorial you will learn about adding audio. Every time our snake eats the apple he makes a gulp sound!

We will learn about collision detection by detecting when the snake eats an apple, hits the edge of the screen or collides with another part of its body.

We will take keyboard input to decide the direction our snake moves in.

Lastly we will add text to the canvas by implementing a game over screen and displaying a score that increments as you eat apples

Snake GitHub source code
https://github.com/CodingWith-Adam/snake

Playable version of snake from tutorial (use arrow keys to move)
https://codingwith-adam.github.io/snake/

Alternate version of snake from GitGub user jeremystone4321 (use WASD keys to move)
https://jeremystone4321.github.io/Sna...


Смотрите видео Coding Snake in JavaScript Complete Tutorial Every Step Explained with HTML5 Canvas онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Coding With Adam 23 Октябрь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 71,272 раз и оно понравилось 1.5 тысяч людям.