Thrusting in different directions

When you press the control key, the player’s ship will accelerate in whatever direction (0-23) it is facing. To make this possible, I pre-populated a couple of float arrays with values x and y for thrust in any of the 24 directions.
This function populate the two arrays. These are declared as
float thrustx[24];
float thrusty[24];
void InitThrustAngles() {
const float pi = 3.14159265f;
const float degreeToRad = pi / 180.0f;
float degree = 0.0f;
for (int i = 0; i<24; i++) {
float radianValue = degree * degreeToRad;
thrustx[i] = (float)sin(radianValue);
thrusty[i] = (float)-cos(radianValue);
degree += 15;
}
}
It uses trigonometry to calculate the horizontal and vertical amounts for any of the angles 0,15,30..345 degrees. As sin and cos functions work in radians rather than degrees, the variable radianValue is calculated from the degree angle by multiplying by the value degreesToRad. If you remember your school trigonometry, one radian = 180/pi degrees. So the code divides by this value (or multiplies by its inverse in this case).
Then when you press the control key, it just adds the appropriate thrustx and thrusty value to the vx and vy variables. Simple and fast.
The screenshot is of an open source command line editor for Dos, Windows and Linux called
Running a game at 60 frames per second means that handling things like key presses can be interesting. In the game, I call various SDL functions and via a giant switch statement set flags. Then later in the game loop, those flags are used to determine actions
In the asteroids game, when you press the s button to put up a shield, it draws a circle. I must confess, I didn’t know how to draw a cuircle so looked it up and found an example on StackOverflow. You can use code from 
The traditional way of using an include guard is to put all of the header inside a #ifdef like this.
that you can try are based on Linux but there are a few that aren’t.
I’m changing horses in midstream so this won’t appear as it’s been done so far. Rather than let it go to waste, I’ll be publishing it in parts here. My next book will be Learn C Games Programming on the Raspberry Pi.