I’m not asking advices about what language or environment is better to start with because my current plan is to play with a roguelike project and I already decided I’ll try doing it in Python and libtcud (a sort of advanced console library that is becoming the standard for not barebone RLs). Though I’ll also put some time into C++ so I’ll probably end up arbitrarily mixing Python and C++ if it can be done without major headaches.
But before I get there I have some unfinished businesses from more than 15 years ago. As my first approach to C I decided to write a kind of RPG engine tile-based similar to the SNES Final Fantasy. I was on MSDOS and using DJGPP with the Allegro library. Some ANCIENT stuff!
Because the Allegro only gave you the barebones to draw bitmaps and so on, I ended up wasting all my time trying to build a sort of GUI, so building functions to make buttons work, get input string for the character’s name using a custom bitmap font (which remains the most complex function I ever wrote, and that worked at the first try) and so on. And finally I was able to have an animated sprite in the center of the screen walking around with the background scrolling (with step sounds!).
The major roadblock that I was never able to overcome (I had no internet to figure out stuff) was that the program ran great on my PC, but when I tried it on a friend’s PC suddenly the sprite was running around at BLAZING speeds. The reason is quite obvious looking at the source code now, since I “paced” the whole program through frequent use of the rest() command. That obviously was custom tailored for my own PC but that wouldn’t have worked on different hardware.
At the time I tried to fix it but the only text I had about interrupts and timer seemed to call some assembly functions that messed with a timer that would either crash my PC or make the computer clock go insane. In the end I never figured out how to fix it, and the project died right there.
I STILL have no idea how you deal with those problems. I still have my mind stuck with the fact that a program cycle runs as fast as it can, following a precise order, and I don’t understand how you can run some parts so that they have a consistent output that doesn’t change with the hardware power. I GUESS that a solution was to bind my sprite animation routine so that each frame was drawn at a sort of regular “tick” (and so keep the timer active only when animations happen, then simply idle and wait for player’s input, but that implies that the world freezes if the players doesn’t give a command), but I remember that at the time my attempt was to run the ENTIRE game loop on a timer, but I was never able to compile it without errors.
So, at a very basic level, how do you deal with those problems nowadays? Say that I want to write a Hello World program with the standard I/O compiled with Code::Blocks and MinGW (so it goes on a windows console), how do I print the string if I want to delay it exactly by one second? How do you set those sort of things when you want in a game that certain things happen at a precise time or pace?
Also, where the f*ck I tell Code::Block to compile with -llallegro library (I suspect that including Allegro.h isn’t enough to call it automatically)? And how can I let it show me the output of the command line it gives, since it only seems to show me errors and such? I mean I want to SEE it call “gcc.exe -c rpg.c -lallegro” so that I can see what it is doing, or something like that…