Search Projects

Tuesday, February 21, 2017

Car Race OpenGL Program

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. 



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.


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

Color change
Change the track and background color (when game end and show shown).
0 - to white
1 - to red
3 -  to blue

Game Play
2 - down or de-accelerate
4 - toward left
6 - toward right
8 - up or accelarate


Note : In this OpenGL program we have used the glutStrokeCharacter

NAME
       glutStrokeCharacter  -  renders  a  stroke character using OpenGL.

SYNTAX
       void glutStrokeCharacter(void *font, int character);

ARGUMENTS
       font      Stroke font to use.

       character Character to render (not confined to 8 bits).

DESCRIPTION
       Without using any display lists, glutStrokeCharacter  ren
       ders the character in the named stroke font. The available
       fonts are:

       GLUT_STROKE_ROMAN
               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.

       GLUT_STROKE_MONO_ROMAN
               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.

Friday, February 17, 2017

Flag Hoisting Graphics Programs in C/C++

There are many Graphics Program available for C/C++. In our website we have posted so many Graphics Programs in C/C++ which used the OpenGL graphics library. While there few program available for turbo C which used the graphics.h library, but they are outdated. The new time is to adopt opengl, one point to support this is that OpenGL is opensource. The API provided by CGI has so many that we can render to make some good game or other animated programs. You can became a game developer by mastering the graphics programs.Visit OpenGL.org for more. Don't forget to visit the forum.

This blog is dedicated to OpenGL programming and we are focusing on that only, but sometime off topics are good to have. Before getting stated with opengl, we aspect that you all have some knowledge of C/C++. All the programs posted here are written in C/C++ or otherwise mentioned.

Today we are going to see the Flag Hoisting Program in C/C++. This program is submitted by +Srikanth Kini.

Flag Hosting Graphics Programs in C C++


Aim of the Project : The projects objective to show graphically hoisting of a Flag.

Description of the Project : In this project we have 3 people, a flag pole and sun. All these objects are drawn using the basic primitive functions provided in OpenGL. At the beginning flag is down, which is hoisted by a person (first among the three) who walk toward the pole. There is little complication in here as the person don't seems to walk rather moving toward pole. Since this is 2D project it not look realistic.

The person approaches the flagpost and host the flag, which is shown with a good animation. Flag go up and waves out. This is unlike the previous waving flag graphics program in C/C++. There is "Vande Matrama" written in right side as  flag waves. The salutes can also made with animation, which look awesome.

User Interaction : This program has no much user interaction but few. In the beginning as program start there is no motion, so there is s/S key which initiate the  program animation. As s/S is pressed the person in front start moving to host the flag. To exit, just press esc key.

Video Demo



Future enhancements :
  • Convert the Whole Program into 3D version.
  • There are only three people there, more can be added with a proper stadium.
  •  Make the motion more realistic.
  • Flagpost and other can be improve with better quality of graphics design.
  • Sound can be added with National anthem getting sung as flag get hoisted.
  • Flowers should fall as flag get hosted.
To get the source code for this Graphics Programs contact us to our email - openglprojects@gmail.com. Put your comment and let us know your views.