Rustlang Project: Snake Game -

Rustlang Project: Snake Game

Tensor Programming
Views: 27790
Like: 649
Our first full length project in rust. In this video we code a full featured Snake game using the piston game engine and everything that we’ve learned thus far in Rust. We also briefly touch upon the rust Namespace system and the rust Library system.

Feel free to donate:
BTC: 1ExBSiaEa3pceW98eptJwzR9QHrYZ71Xit
ETH: 0x5eeD69F1AD48095bFd2845483fdb63B7148B3eDa

Github Source Code:

Check out our Blog:
Check out our Twitter:
Check out our Facebook:
Check out our Steemit:


  1. You sir are legend!! Thank you a lot for the efforts!! I was wondering, if you will do some demo project concerning system programming e.g. create a simple file explorer?

  2. First of all I must say that I'm loving all your playlist about Rust,
    Second thing, Can you made a video showing ho config VS Code to work with Rust.

  3. I really enjoy the fact that you copy and paste code chunks and explain them vs wasting time typing them out. my only complaint, your indentations, and layout of some parts are odd.

  4. Thank you very much for these precious lessons!

  5. Hi, Tensor, Thanks for your tutorial of Rust. I just wonder what plugin you installed that can see some hint or source code of Rust?

  6. Great video. Just wondering how you got your cmd window to look like, or are you using some other shell?

  7. Thanks for your video, it's really nice. Learnt a lot as a new ruster!

  8. What a great tutorial series! It is actually the best for Rust that I've been looking for. A side question, do you play CS as I saw you have Steam running and in one of the CS servers there is one player whose voice is very similar to yours. 🙂

  9. Thank you for these tutorials. They are fantastic.

  10. At 25:20 you unwrap an Option of Direction. But that ignores the possibility that it might be None, and it would panic. Please correct me if I am wrong – I am just newb Rust learner. Maybe your source code on Github has this bug fixed, didn't check it on purpose, just coding along with you, watching the video.

    Btw, great course, feeling much more confident with Rust now, thanks to you.

    Update: just checked your code, it's all the same. I suspect the code will blow up horribly when you press anything but arrow keys.

  11. I am new to Rust but learned a lot from the previous videos and coding along this one. How to download and use external libraries, import modules and most of the language basics. Thanks!

  12. A little overwhelming for me ( total noob )
    Will have to watch this and the preceding videos multiple times before I truly understand it all.
    But thank you, this is an amazing resource!

  13. Where can I get your font?? I love how it converts ==, => and -> into single characters.

  14. Awesome! Although I know it's not up-to-date with the latest features of Rust, I really loved building the game step by step with good explanations on what's actually happening! I'm fairly new to Rust and systems language programming in general, so this playlist helps a lot! 😀

  15. Thank you for the video, I've actually learned very much from it. But you're a dick for omitting the return keyword everywhere, it was really confusing at the beginning 😀

  16. This good technically but not agile. We never write a game this way.

  17. Awesome video! But I don't understand well when to use extern crate instead of use …

  18. For anyone getting an error saying imports have changed in Rust 2018, use crate:: before all imports that are from your project files, eg. instead of "use snake::{Direction, Snake}", write "use crate::snake::{Direction, Snake}".

  19. Great tutorials! Thanks. I am having a problem with a file when I build after adding the crates. error[E0658]: use of unstable library feature 'alloc': this library is unlikely to be stabilized in its current form or name (see issue #27783). The current version of piston_window is 0.105.0. I tried using the same version you use on the video (0.74.0) but it doesn't download (maybe too old???)

  20. A great tutorial indeed and you even updated the part where draw2d got an error in the source code. Ty so much Tensor.

  21. Still can't figure out where is this .dt from. Do you mind explaining those lines?
    event.update(|arg| {

  22. There is a little bug where when you hold down a key instead of taping it the snake will enter SUPER SONIC mode. This is because the key_pressed function , calls update_snake, however update_snake does not check for the MOVING_PERIOD and updates the position every frame the key is held down.

  23. I'm new to Rust and this tutorial taught me tons of new things. THANKS FOR MAKING SUCH A GREAT SERIES!

  24. hi , super awesome explain, can you increase volume up ? hahah

  25. Thanks, brilliant turorial. Learned so much and after fixing the 2018 changes to Rust, it runs great on Ubuntu 20.04.

  26. In the next_head() function the match dir returns an error, we are specifying an (i32, i32) return type, but are actually returning a Direction. Any workaround?

  27. At 34:51, the code for draw_2d window should look like this: window.draw_2d(&event, |c, g, _| – note the underscore in the closure | c, g, _ | – the underscore is not present in the video (but the program compiles anyway!). This gives an error when I run it and the workaround is to include the _ . Hope this helps anyone learning this in 2020. 🙂

  28. Thought I'd add a comment that use draw::draw_block is deprecated now, it's use crate::draw::draw_block 🙂 I'll edit this if I find any more, oh also the inclusive operator now is ..= if you wanted to add that annotation in on your last video, either way these tutorials are great

  29. Hey Tensor, I noticed draw_block being almost identical to draw_rectangle and would like to use partial function to re-define it, is partial application the same thing as a partial function? if not, how would you do it in rust? Thank you

  30. A few minor hiccups due to the language changes, but otherwise a great tutorial. One question though: when I run my project, the window is very small, and I need to manually expand it. How would I fix it so that it would run properly and show the whole game when I start it?

  31. Nagyon jó!! Sokat tanultam belőle. Köszönöm 🙂

  32. Thank you for the great tutorial! This video is still relevant 3 years later.

    A question: pattern matching with 'match' is better than if/else statements?

  33. Loved building this 😀
    One question, while the game works when I run it through `cargo run`, it doesn't work when I `cargo build –release` and try to run the resultant `snake.exe`. Do you know why this is, or how I can fix it?

  34. Thanks so much for the tutorial! I just cloned the repo, then attempted to `cargo run` the game but unfortunately encountered this error:
    thread 'main' panicked at 'attempted to zero-initialize type `glutin::ContextWrapper<glutin::PossiblyCurrent, glutin::Window>`, which is invalid'
    Any idea what might have cause this? I'm using MacOS BigSur. Thanks.

  35. Hey, thats a brilliant tutorial mate! But I find it difficult to develop such logics, well in this case, i find it difficult in understanding the purpose of each function, is it a beginners dilemma or should i have to do something?

  36. Actually, instead of gen_range(1,self.width-1) we can now put gen_range(1..self.width)

  37. 16:30 Do we have to call unwrap() on that removed_block, and on following line rewrapping it into Some()? It's already an Option<>, so what's the point?

Leave a Reply

Your email address will not be published. Required fields are marked *