Let's also revise our "my_mvaddstr()" function to use a different method of trimming the string, just so you can see a different way of doing it.
Trim A String Using Yet a Third Method
Let's also revise our "my_mvaddstr()" function to use a third method of trimming the string, just so you can see yet a different way of doing it. Replace all of "my_mvaddstr()" with the following:
Feel free to use whichever method makes the most sense to you (the third is probably the cleanest; it's the method I'll use). Also, keep in mind that Rust encodes strings as UTF-8, not as ASCII, and each of these three methods will break the program if the image being drawn uses a character outside of the standard ASCII subset of UTF-8. You can see this by temporarily adding a multi-byte character (e.g. ท) to one of your images, like so:
Try running the program with the "boat" option ($ cargo run -- --kind=boat) and you'll see that the program now crashes. (Remember, Ctrl-C, followed by blindly typing "reset", should return your terminal to a usable state.)
The solution is to either limit the ASCII-art images to using the ASCII subset of characters within the UTF-8 character set (as we are doing; so don't forget to remove that temporary ท character from your image), or to use a more robust trimming method as well as something other than ncurses (perhaps ncursesw, but that crate is a different critter, and isn't as much of a drop-in replacement for the curses used by the C-version of "sl").
If the animation is too slow for you, decrease the "delay" setting in "main()". If the animation is too fast, increase the "delay". Soon we'll make the speed an option.
We now have an animated image that moves across the screen. Well done!