Linux E-book Progress
My Linux rewrite continues with progress as far as chapter 38.
This is the first Linux version of asteroids on the left and is a demo of the text writing routines and also loading images from files.
It;s drawing all digits from 0 to 99 at random locations on the screen every frame.
The number at the top is how long it takes to output the text. That value if you can’t read it is 0.000622, which means it takes 622 microseconds to output 100 numbers or 6.22 micro-seconds each.
This is the routine that does that.
void RenderEveryThing() {
int atX, atY;
renderTexture(textures[PLBACKDROP], 0, 0);
startTimer(&s);
for (int i=0;i<100;i++) {
atX = Random(WIDTH-50) + 1;
atY = Random(HEIGHT) + 20;
TextAt(atX, atY, SDL_ltoa(i,buffer,10));
}
stopTimer(&s);
SDL_RenderPresent(renderer);
frameCount++;
UpdateCaption();
}
The most recent uploaded code version (chapter 37) lets you move the player’s ship around (press q, w or ctrl) , fire bullets (space bar), press a to see random asteroids rotating and moving round (and off) the screen. Press the b key to blow up a few asteroids with explosions and sounds. Enjoy!
Zipped up source code, graphics etc from the forthcoming Linux book can be downloaded from Github.
I’ve used diff and merge tools since the year dot. They let you compare two files and see on what lines they differ. You can also copy individual or blocks of lines from one to the other; that’s the merge. My all-time favourite was the commercial Araxis Merge which did a three way comparison and could be controlled by COM. I did this to compare two code bases.


Match Three games have been around for the best part of a decade and have a basic mechanic of swapping two adjacent pieces to make a line up of three, four or five pieces which get removed.
What makes possible all of the fast graphics in SDL2 is really one instruction.
In the Empire game (yes, just one last mention!) during the map generation the program counts up the size of individual islands and sea areas. This is don by recursion and quite useful. Otherwise, the usual place you see recursion mentioned is in calculating factorials and Fibonacci sequences.