There are many OpenGL Program in our blog. In this post we are going to discuss about the Car Race game in old style. It is similar to 2d c...
There are many OpenGL Program in our blog. In this post we are going to discuss about the Car Race game in old style. It is similar to 2d car racing game but little simple.
Like in video game Car race game, we have seen the cars are shaped in rectangular shape. The black meter lined road is coded on which the cars raced. There are 6 lanes in the road on which racer have to move the care to avoid collision.
You may learn, how to draw 2d moving car using opengl.
Earlier in our many game programs we have much impressive menu or instruction for user. This opengl program also display the menu while game being played. You can see in the image above. The score is also written at the top.
Also see -3d car racing game in openGL
HOW TO PLAY
In menu the basic instruction has been shown but many skipped due to low area to display text. All the other user interaction of this opengl program are mentioned below -
Start and End
s - start the game
q - quit the game and exist the program
Change the track and background color (when game end and show shown).
0 - to white
1 - to red
3 - to blue
2 - down or de-accelerate
4 - toward left
6 - toward right
8 - up or accelarate
Download the source code of this opengl program.
Note : In this OpenGL program we have used the glutStrokeCharacter
glutStrokeCharacter - renders a stroke character using OpenGL.
void glutStrokeCharacter(void *font, int character);
font Stroke font to use.
character Character to render (not confined to 8 bits).
Without using any display lists, glutStrokeCharacter ren
ders the character in the named stroke font. The available
A proportionally spaced Roman Simplex font for
ASCII characters 32 through 127. The maximum top
character in the font is 119.05 units; the bottom
descends 33.33 units.
A mono-spaced spaced Roman Simplex font (same
characters as GLUT_STROKE_ROMAN) for ASCII characte
ters 32 through 127. The maximum top character in
the font is 119.05 units; the bottom descends
33.33 units. Each character is 104.76 units wide.
Rendering a nonexistent character has no effect. A
glTranslatef is used to translate the current model view
matrix to advance the width of the character.