Posted By

sgreaves on 02/10/14


Tagged

main game engine model interface c++


Versions (?)

C++ Game Engine Main Interface


 / Published in: C++
 

This is the cpp file given to the users of the game engine I am creating for the 3rd year uni project. It shows what the user is given and a sample of how easy it is to load a model.

The areas marked with user code is an example of the code a user will need to implement. The output from the engine can be seen in the following image:

http://i.imgur.com/5WEYnHR.png

  1. //--------------------------------------------------------------------------------------
  2. // Game Engine Demonstration
  3. //
  4. // Purpose: Demonstrate how easy it is for a user to create a model
  5. //
  6. // Date: 09/02/2014
  7. // Author: Sam Greaves
  8. //--------------------------------------------------------------------------------------
  9. #include "gameEngine.h"
  10.  
  11. // create the game engine interface, could make more than just a directx engine
  12. IDevice* gameEngine = newGameEngine(kDirectX);
  13.  
  14. void main()
  15. {
  16. // Start the game engine in a window of default size
  17. gameEngine->StartWindow();
  18.  
  19. // Add the media folders where the content is stored
  20. gameEngine->AddMediaFolder("Media");
  21.  
  22.  
  23.  
  24. // User code
  25. //------------------------------------------------------
  26. // Creates a mesh and a model of that type
  27. IMesh* testMesh = gameEngine->CreateMesh("Cube.x");
  28. IModel* test = testMesh->CreateModel(0.0f,0.0f,0.0f);
  29.  
  30. // Creates a camera thats needed to view the game world
  31. ICamera* gameCamera = gameEngine->CreateCamera(20.0f, 20.0f, -50.0f);
  32. //------------------------------------------------------
  33.  
  34.  
  35.  
  36.  
  37.  
  38. // Main game loop here
  39. while(gameEngine->IsRunning())
  40. {
  41. // Engines render code
  42. gameEngine->DrawScene();
  43.  
  44.  
  45. }
  46.  
  47. // deletes the game engine pointer and releases everything
  48. delete(gameEngine);
  49. }

Report this snippet  

You need to login to post a comment.