3.5  25 reviews on Udemy

Snake Game With Rust, JavaScript, and WebAssembly

Build a Real Game With Rust and Javascript
Course from Udemy
 229 students enrolled
 en
Connect JavaScript and Rust with WebAssembly
Game Development Basics
Practical Applications of Vectors

In this course, we will build a Snake Game with Rust, JavaScript, and WebAssembly. We will learn how to export API implemented with Rust to JavaScript app. We will get to know canvas rendering, applications of vectors, and basics of game development so that at the end of the course, you can take the core of this project and improve it or create your game.

Before we start writing code, we need to have a clear vision of what we are going to build. Let's first decide on what features the game will have and how it will look like so that we can make a plan of action.

We are going to build a classic snake game that you can see on the screen. When the snake eats food, it becomes longer, and the score increases. If the snake heats the wall or bites the tail game is over. Additionally, we will allow the player to stop the game by pressing the space button. To keep the user motivated, we will save the best score and show it alongside the current one. We make sure that the game looks good on any screen size, be it a tiny mobile phone or a large TV.

We want each component of the game to be as independent as possible. We will implement the core logic of the game with Rust and will export API to JavaScript via WebAssembly.

The main thing that we will export from Rust is Game struct with a constructor and two public methods. The first method will receive a duration from the last update and direction that the user wants a snake to take. The second method will check if the game is over.

On the JavaScript side, we will run the game loop, call API methods, render all game elements, capture user input, and save the best score.

Now let's plan how we are going to make it all happen. First, we will install the tools needed for development and start the project. Then we will create an instance of the Game struct from JavaScript. Next, we will render all the objects of the game. Then we will implement logic to place food in a random place that is free from the snake. After that, we will start the game loop and make the snake move. Next, we will allow the user to control the snake direction and stop the game. After that, we will make that every time the snake eats the food, its tail grows longer. Finally, we will complete the development of the game by adding logic that will restart the game when the player lost and deploy the game.

All the source code you can find in the repository. Each part will have a link to the corresponding commit. There are a lot of things to cover in this short course, so let's jump in.


Snake Game With Rust, JavaScript, and WebAssembly
$ 19.99
per course
Also check at

FAQs About "Snake Game With Rust, JavaScript, and WebAssembly"

About

Elektev is on a mission to organize educational content on the Internet and make it easily accessible. Elektev provides users with online course details, reviews and prices on courses aggregated from multiple online education providers.
DISCLOSURE: This page may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.

SOCIAL NETWORK