Don't know if this is the right place to ask, but here I go
I'm a complete noob at programming, so I wanted to make a simple SDL2-based game framework as an exercise. I've managed to make it do what I wanted (Draw sprites, play sounds, draw primitives, pixel art etc.), BUT
It's absolute jank. Extremely janky, scrapped it together in like two days. I don't know anything about SDL, so for everything I just googled "SDL2 how to thing" and tried to translate it to Nim. If it didn't work I just randomly changed pointers and variables until it did. Horrible development all round, pretty sure I just copypasted the boilerplate from some tutorial.
Also It doesn't work with the new Nim version.
Basically, I'm looking for someone who is more experienced with Nim to help me sort this out.
O shit it does lol
Sorry, I guess it didn't work on some other version haha. Anyway, the problem isn't it not working (it does), it's just that I feel like I made it wrong, since I don't know alot about this stuff, so i would feel a lot more confident if someone knowledgeable would check it out and improve it.
Then make it better? What you describe is basically how I program. Probably how everyone programs. Eventually I learn how the thing works and can comeback to cleanup my exploration code. At first I copy stuff from Stack Overflow and where ever... then some times try out permutations of things till they work, but after I figure it out there are probably better, cleaner ways of doing it... I might come back years after, and clean stuff up. Its the process.
Make it work. Make it work better.
I am not experienced enough to see where I could make improvements.
I've just skimmed through your repo and the first place where I would start with the improvements is that loooooooooooooooooong case statement.
You could start with something like this (didn't test it, I write it directly here on the forum):
let c = character.toLower()
case c
of 'a' .. 'z':
return c - 'a' + 1
of '1' .. '9':
return 26 + c - '0'
# etc.
This keeps your return values as they are, but this could/should be improved even more.
Fixed it, thanks!
I changed it to allow for more flexibility when using a custom font. Now there is a string, "glyphs", which stores the chars in the font in order, and the function now checks it to return a number.
Also, thanks for reminding me of ranges, I completely forgot about them