How to create a Game Interface

In this example we are going to see how to create a game interface using C++ and Maratis SDK.
We will use the SimpleGamePlugin Demo as a base project, and simply customize the Game class (MyGame.h and MyGame.cpp).

The main idea is to draw a scene with a life bar and a mouse cursor (the GUI scene) on top of one other (the current scene) :

1 : Project creation :

In a new Level create 2 Scenes :

- Scene-1 will be the game scene :
Here some boxes with a perspective camera and a spot light with dynamic shadows

- GUIScene will be the interface scene :

Meshs are done in Blender with a simple textured quad, the blending mode of the Material is « Alpha blending ».

In Maratis, the GUI objects are oriented in X and Y, to be in the same space as the mouse coordinates. To arrange easily the scene in 2d, select the « Bottom » view.

Create a camera oriented toward Z. Then, in the camera properties, select « Ortho » to activate the orthographic projection (2d).

2 : Game plugin creation

We are now going to create a game plugin derived from the SimpleGamePlugin Demo.
- We will modify the game class to draw one scene on top of the other and to move the cursor object according to the mouse position.

Let’s first enable the following functions of the Game class in MyGame.h :

void onBeginScene();
void update();
void draw();

And write the code in MyGame.cpp :

These functions are virtual, if they are not customized, they are executing the standard Maratis code. In this example, we want to draw the current scene normally and just draw another scene on top.

DOWNLOAD THE COMPLETE PROJECT

Cette entrée a été publiée dans Tutorials. Vous pouvez la mettre en favoris avec ce permalien.

3 réponses à How to create a Game Interface

  1. Peter K.H. Gragert dit :

    Fine, the project was opened and converted to a newer MS VC++ ;-)

    But what to do now????

    Des regards
    Peter

    • anael dit :

      It’s a game plugin, you have to compile the project and create a dll named « Game.dll ».
      « Game.dll » need to be in the project root folder.

      Then, launch Maratis, open the project, and the plugin should be on.
      To see the result, launch the game using pacman icon (on top).

      Maybe this tutorial can help : http://www.maratis3d.org/?p=500

  2. Peter K.H. Gragert dit :

    Thanks Anael,
    will try ‘later’ ;-)
    Peter