I do not know how old you are; as someone who's first programming language was batch, and way too experienced in it, I would not recommend pursuing it.
I would recommend pursuing languages such as Python, C-language family, web-development languages...
Alas, here are my suggestions on your programming practices.
Use way more double quotes to easily sanitize most user input, and avoid escaping thus improving readability.
[if "%string%"=="hello world"] (try having spaces in your user input or menus 💀)
[set /a "a=(4+2)*5"]
If you want performance with your echo-align function, consider making it a macro. Also in my opinion you don't need to call 'mode con' every time you print text, just update the variable with a batch of text. Also, building an offset amount of spaces with a for loop is slow. Two faster methods: make a variable consisting of entirely (amount you need) 400~ spaces, then use string slicing to select the desired amount of spaces. So !_SPACES:~0,%amount%!. But I would recommend the latter method, which is using ANSI escape sequences. More about them on this wikipedia link https://en.wikipedia.org/wiki/ANSI_escape_code.
To offset to the middle, just add 'echo %ESC%[%amount%C{text}', where the escape sequences "ESC[xC" moves the cursor x spaces to the right.
Now Windows terminal support... just remove all uses of the 'mode' command to set the window dimensions. It's not that great from a user perspective, and with Windows terminal, the mode con values actually reflect user inflicted change to the window dimensions. The environment variable "WT_SESSION" will be set if running on WT.
Use "echo(" to print out empty lines (according to dostips experts), no it will not cause any kind of problems, nor mismatched parentheses, nor do you need to escape it.
In the end, readability matters most
So what'd I'd do as you is continue subsequent terminal projects in other, better languages. I've had a lifetime's worth of discouragement from batch, I tend to agree, and share some with you.
That asides, if you don't care, batch has an advantage in it's native environment the terminal, since it can access it without requiring to familiarize yourself with the Windows API you might need in other languages if you want to access things like terminal dimensions.
Well farewell, I'll play your game. Funny fake loading screen (I'm guessing).
For input, I use "for /f %%a in ('choice /c "YN" /n') do echo %%a", which will echo out "Y" or "N" depending on your choice, saved in the %%a, that you can save to a variable.
[if "%choice%" == "Y"]
If you're really savvy, you can have you can have your game/scripts automatically update itself. On github, it's really easy. Just a somewhere to fetch the online version from, and download, using the native since Win10 'curl' command. This github repo of mine has automatic script updates: https://github.com/EternalLeo/sound2wem
Thank you for your help and words. Programming is far from my trade (I'm a musician), and only learned batch back when I was young and wanted to make something again now that I'm older. I've thought about learning an "actual" language for some time, and doubt I will make my next project in batch. I would love to have made this game in another language, but I had already done so much work before I realized how much the language was holding me back.
← Return to game
Comments
Log in with itch.io to leave a comment.
I do not know how old you are; as someone who's first programming language was batch, and way too experienced in it, I would not recommend pursuing it. I would recommend pursuing languages such as Python, C-language family, web-development languages... Alas, here are my suggestions on your programming practices. Use way more double quotes to easily sanitize most user input, and avoid escaping thus improving readability.
[if "%string%"=="hello world"] (try having spaces in your user input or menus 💀)
[set /a "a=(4+2)*5"] If you want performance with your echo-align function, consider making it a macro. Also in my opinion you don't need to call 'mode con' every time you print text, just update the variable with a batch of text. Also, building an offset amount of spaces with a for loop is slow. Two faster methods: make a variable consisting of entirely (amount you need) 400~ spaces, then use string slicing to select the desired amount of spaces. So !_SPACES:~0,%amount%!. But I would recommend the latter method, which is using ANSI escape sequences. More about them on this wikipedia link https://en.wikipedia.org/wiki/ANSI_escape_code. To offset to the middle, just add 'echo %ESC%[%amount%C{text}', where the escape sequences "ESC[xC" moves the cursor x spaces to the right. Now Windows terminal support... just remove all uses of the 'mode' command to set the window dimensions. It's not that great from a user perspective, and with Windows terminal, the mode con values actually reflect user inflicted change to the window dimensions. The environment variable "WT_SESSION" will be set if running on WT. Use "echo(" to print out empty lines (according to dostips experts), no it will not cause any kind of problems, nor mismatched parentheses, nor do you need to escape it. In the end, readability matters most So what'd I'd do as you is continue subsequent terminal projects in other, better languages. I've had a lifetime's worth of discouragement from batch, I tend to agree, and share some with you. That asides, if you don't care, batch has an advantage in it's native environment the terminal, since it can access it without requiring to familiarize yourself with the Windows API you might need in other languages if you want to access things like terminal dimensions.
Well farewell, I'll play your game. Funny fake loading screen (I'm guessing).
For input, I use "for /f %%a in ('choice /c "YN" /n') do echo %%a", which will echo out "Y" or "N" depending on your choice, saved in the %%a, that you can save to a variable. [if "%choice%" == "Y"] If you're really savvy, you can have you can have your game/scripts automatically update itself. On github, it's really easy. Just a somewhere to fetch the online version from, and download, using the native since Win10 'curl' command. This github repo of mine has automatic script updates: https://github.com/EternalLeo/sound2wem
Thank you for your help and words. Programming is far from my trade (I'm a musician), and only learned batch back when I was young and wanted to make something again now that I'm older. I've thought about learning an "actual" language for some time, and doubt I will make my next project in batch. I would love to have made this game in another language, but I had already done so much work before I realized how much the language was holding me back.
Elroth 1.2 is released!
Elroth 1.2 will be releasing soon. Update will include MANY bug fixes, a new secret class, new items, NG+, and many more small quality of life fixes.