This is my first ever rust project please be nice
#Code Review Request -- Rust Snake Game
11 messages · Page 1 of 1 (latest)
The recording of demo files would be useful: https://www.youtube.com/watch?v=_uWmE0EduFE&lc=Ugxi_b8mD7fI_tT1iyF4AaABAg
Check out Hostinger's AMAZING BLACK FRIDAY SALE (ends Dec 5, and don't forget to use coupon code CHERNO for a bigger discount!) ► https://hostinger.com/cherno
Patreon ► https://patreon.com/thecherno
Instagram ► https://instagram.com/thecherno
Twitter ► https://twitter.com/thecherno
Discord ► https://discord.gg/thecherno
This video is sponsore...
First off, nice job. Code ran on my machine first try (after installing libsdl2-dev). The window resized correctly too when I edited the width and height parameters.
Here's some advice on your code from what I noticed:
Some of your trait bounds in Point2 look a little funky and might be able to be simplified (looking at impl block). It also might be possible to get rid of completely the IPoint2 thing, but this is not really a concern
Here's some advice on the user expr. (controls, game, etc):
The stickiness in the controls needs a bit of reworking, for example: if I'm holding down and then start holding right at the same time, the snake should move right (not continue down).
A bit of repo advice: add a few more things to your .gitignore, no need to have vcpkg folder, log.txt, or rust_snake.iml tracked in version control
Looks good though!
Lastly, don't ignore the compiler warnings that it gives you and run cargo fmt as well
@lime vigil Thank you so much for your review! Every piece of advice was helpful.
The biggest reason why I included the vcpkg files is that if anyone had a 64 bit windows machine, they could run it without downloading SDL. I don't have 32 bit machine so I rarely ever publish 32-bit content.
About the controls, I think I found this issue why holding the key did not work. I check which key is currently down in a set order, which will bias how gameplay works when multiple keys are pressed. This is an honest mistake, at the time I completely did not realize that players may press multiple buttons at once. To handle such a thing, I will probably need to implement an input buffer system.
You’re welcome! And yes, including the vcpkg would work to users not wanting to download SDL so it’s reasonable to keep however it won’t work for Linux machines 😉