Object Oriented Programming C++ (M1 QDCS)

 
Bibliographic references

 
The C++ programming language, Bjarne Stroustrup
The C++ primer, Stanley Lipmann

 
Programming project

2024: Treasure hunt in a labyrinth haunted by hostile robots

      Specifications of the project.

Example of a labyrinth

This is an example of labyrinth.

Prototype for Linux (Fedora and Ubuntu), MacOSX and Windows

You will find in the labh-proto-fltk.tgz archive the game prototype. This prototype uses the FLTK graphical toolkit (https://www.fltk.org) which runs on all three major systems. A pre-compiled version is provided in the fltk-1.4-linux, fltk-1.4-ubuntu, fltk-1.4-macosx and fltk-1.4-windows directories.

This version, once unpacked, contains the following files:

    Chasseur.cc      Labyrinthe.cc   OpenGL-macosx.o   fltk-1.4-macosx/   modeles/
    Chasseur.h       Labyrinthe.h    OpenGL-ubuntu.o   fltk-1.4-ubuntu/   sons/
    Environnement.h  Makefile-proto  OpenGL-windows.o  fltk-1.4-windows/  textures/
    FireBall.h       Mover.h         Sound.h           fmod/
    Gardien.h        OpenGL-linux.o  fltk-1.4-linux/   labyrinthe.txt

  • Attention: the files Environnement.h, Mover.h, FireBall.h, Sound.h must NOT be modified!
  • Gardien.h, Chasseur.h, Chasseur.cpp, Labyrinthe.h and Labyrinthe.cpp which are examples and which you must rewrite based on those!
  • The sons, textures and modeles directories contain respectively the sounds (.wav or .mp3 files) the images of the walls, posters etc. (.jpg or .gif files), and the models (.md2 and .jpg files). (.jpg or .gif files), and the guard models (.md2 and .jpg files).

    These directories are already pre-populated with sounds, images and characters. The code provided as an example as well as the one you don't have the sources for (OpenGL<system>.o) look for these files in these directories.

  • The OpenGL<system>.o files contain the graphical interface (whose sources are not provided)
  • The FMOD library is used for sound on Linux Fedora (it is useless on Ubuntu Linux, Windows and MacOSX, which have sound features built-in).

    The Makefile-proto file contains everything you need to compile the prototype with g++ on Linux and MacOSX and with MinGW-w64 on Windows, which you can get at the URL:

    	https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download
    
    or get the installer here: mingw-w64-install.exe.

    You will also need the make command which you can download at the URL:

    	http://gnuwin32.sourceforge.net/packages/make.htm
    
    Click on the Setup link to the right of "Complete package, except sources" (first link in Download) which will allow you to get an installer.

    You can easily get the installer here: make-3.81.exe.

    Once mingw and make are installed, remember to update the PATH environment variable so that they can be easily found by the shell: (last two lines)

    To compile, whatever the system, you will just have to say in a terminal the command

    	make
    
    This makefile automatically determines your system type. You will get the labh executable for Linux and MacOSX or labh.exe for Windows.

    To compile, under Ubuntu 18.04 or newer, you can user the following command:

    	make OS=Ubuntu
    

    Some useful functions

  • void partie_terminee (bool)

    Call this function with 'true' if the player has won and 'false' if he has lost. In both cases it will disable the possibility of shooting for the hunter and it will display the message 'You Win!' or 'You Lose!

  • void message (char* format, ...)

    displays a message at the top left of the window. This function is of type 'printf', with a variable number of arguments of any type.

    message ("Nombre de gardiens restants: %d", nb_gardiens);
              // affiche le nombre de gardiens.
    ...
    message (""); // efface le message précédent.
    The first argument has the same syntax as for the 'printf' function ('man printf' for more details).

  • The sound system allows to control the volume and the stereophonic position of a sound. For this the Sound::play function has two (optional) arguments:

    void Sound::play (float volume, float pan)

    'volume' is a number between 0 and 1 (the bigger it is, the louder it is)
    'pan' is a number between 0 (left) and 1 (right).

  • Some character models for your guards

  • Marvin: Marvin.md2 et Marvin.jpg
  • Potator: Potator.md2 et Potator.jpg
  • Droid: Droid.md2 et Droid.jpg
  • Squelette: Squelette.md2 et Squelette.jpg
  • drfreak: drfreak.md2 et drfreak.jpg
  • Blade: Blade.md2 et Blade.jpg
  • Lezard: Lezard.md2 et Lezard.jpg
  • Samourai: Samourai.md2 et Samourai.jpg
  • Serpent: Serpent.md2 et Serpent.jpg
  • May the Force be with you - Patrick Amar