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.