Writing a basic game with C++ and OpenGL libs – part 001.

This is a first part tutorial about Linux game using C++ and OpenGL libs.
Writing a C++ game can be difficult.
You will need to focus on program structure and then to know how to create the necessary classes.
Let’s see the files I used:

The main.cpp file is the main program.
This file will make the window program and will deal with the user.
Also, this file uses OpenGL libs.
Let’s see the source code:

The next two files: display.cpp and display.hpp is used to display the game objects.

I use just one class: Display.

Let’s see the header file display.hpp

… and display.cpp.

You can see the OpenGL source code to make a rectangle.

The next files game.cpp and game.hpp is used to make all game engine working.

The header file game.hpp is:

… and also game.cpp.

Let’s make the Makefile.

This can do well if you know how working g++ compiler.

Use the command to make the binary file:

The result is this:

simplegame tutorial c++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.