Today I implemented a working shell to input commands to the game.
It was surprisingly easy, free of errors and bugs, and a very satisfying job.
First I managed to create the background of the shell, then I added 15 lines of text on it, and I spent a few hours adding multiple features:
- Reading text instead of button signals thanks to a SDL 2.0 feature
- Tab to show/hide the shell
- Enter to scroll the lines like in a standard bash
- Read commands when '\' is read, and stop reading when ' ' is read.
- Read parameters after a command, it works for both string and int parameters
- Different error messages (if argument is missing or is different, the message is not the same)
- Multiple commands on the same line
Except the last point which was a bit tricky, everything went pretty smootly and I don't think there are bugs until now.
In the picture there are a few examples of commands I implemented:
-\hide: same thing as the tab key, really not that useful
-\shellcolor: changes the color of the shell text, accept 3 ints
-\echo: output the string argument as is
In the next days I'll add other features, and add commands to actually control the game.

Nessun commento:
Posta un commento