Rust Journey – Snake Clone – Day 4

I started this iteration by fixing a few bugs and then proceed to add the screens for the different game states(game over, main menu, high scores). It was a quick and dirty iteration just before calling it a day. But since everything happened within 24 hours I am mentioning it.

Then, I created modules for every screen and improved the code to remove any duplicate code and redundancy. Now every screen module is composed of two main functions: render and handler. The further first dealt with key codes but soon it changed to all events.

I committed my changes and started working with the high scores, both recording the values into a file and also fetching it. I got everything working, except the high score display. Dealing with Strings or str within structs or returning was a mess. I went into many lifetime issues when working with it.

I decided to ditch everything related to the high-scores and start over. No git commit was done.

Final Notes

I like to have small iterations to get something working followed by a refactor, but this time I had to rethink my strategy. I understand the causes of the issues I ran into, but I am still learning the language to know how to deal with it.