This is an old revision of the document!
This racing game is a demonstration of using ARM-CAN UserInterface module to display 2D graphics on the LCD and use the joystick. The game itself is very simple – user has to drive the car on the track as fast as possible and there are no opponents nor obstacles on the track. Steering and driving is accomplished by moving the joystick. The program is made of several C source files which each take care of different tasks.
There are structure data types to hold information about 2D points, track sections and the car. All of them are declared in “types.h” file.
typedef struct { short sX; short sY; } tPoint; typedef struct { tPoint pPosition; unsigned short usRadius; } tTrackSection; typedef struct { short sRadius; unsigned long ulAngle; } tPolarPoint; typedef struct { long lVelocity; long lSteering; tPoint pPosition; unsigned long ulAngle; unsigned long ulColor; unsigned long ulLapTime; tBoolean bOnFinishLine; } tCar;
The main function resides in “racing_game.c”.
int main(void); void DoCarDriving(tCar *pCar); void PrepareCar(void);
void GrPolyDraw(const tContext *pContext, const tPoint *pPoints, unsigned long ulNumPoints, unsigned char ucClosedLoop); void GrPolyFill(const tContext *pContext, const tPoint *pPoints, unsigned long ulNumPoints);