Array vs pointer in C

A common pattern (I use the word loosely) in my C programs is to have an array of structs to hold things like asteroids and bullets in the game. There are two ways to process an array:
- As an array e.g. asteroids[index].
- As a pointer to an individual array element. Asteroid * pAsteroid = &(asteroids[index]); then refer to pAsteroid ->
One of the tents of software design though not that often said is that the easier the code is to read, the easier it is to understand. Programmers spend a lot of time reading code. Anything that lightens the cognitive load is good. I suspect it might also be faster, but not by a great deal.
Of course pointers make some programmers nervous. To me though they simplify the code. There is however another way to simplify the code. Use #define so you might have something like this:
#define table asteroids[index]
So everywhere you have a asteroids[index]., you put in table instead.
This for example from Chapter 36 DrawAsteroids()
for (int i = 0; i<MAXASTEROIDS; i++) {
if (asteroids[i].active) {
numAsteroids++; // keep track of how many onscreen
int sizeIndex = asteroids[i].size; // 0-3
int asize = sizes[sizeIndex]; // asteroid size 280,140, 70,35
target.h = asize;
target.w = asize;
asteroidRect.h = asize;
asteroidRect.w = asize;
asteroidRect.x = asize * asteroids[i].rotdir;
target.x = (int)asteroids[i].x;
target.y = (int)asteroids[i].y;
Would become
for (int i = 0; i<MAXASTEROIDS; i++) {
if (table.active) {
numAsteroids++; // keep track of how many onscreen
int sizeIndex = table.size; // 0-3
int asize = sizes[sizeIndex]; // asteroid size 280,140, 70,35
target.h = asize;
target.w = asize;
asteroidRect.h = asize;
asteroidRect.w = asize;
asteroidRect.x = asize * table.rotdir;
target.x = (int)table.x;
target.y = (int)table.y;
What do you think?


Back in November 2018, I was in Nottingham and passed a stand at the Winter Fayre. It was offering a console with 18,000 games on it for about £70. I bought one and what I got was an Orange PI with a 16 GB SD Card (all but full) and two USB joypads.

This is a screenshot of it as it stands and yes those asteroids are moving! It looks identical to the C version; the only difference is the code, not the appearance.
I got my Pi 4 a week ago and have been doing experiments on it with my Asteroids game. If I disable the line of code that kills the player ship in the DestroyObject() function and just add a return after case tPlayer: and uncomment the code that adds Asteroids when you press A then I can have lots of asteroids on screen. Also set the MAXASTEROIDS #define to 128.
I was interested in seeing what frame rate I got out of it and how much it warmed the PI.
I made the mistake of starting by trying to convert the final version of Asteroid; all 2,200 lines of C into C++.