LCOV - code coverage report
Current view: top level - src - Engine.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 41.2 % 17 7
Test Date: 2026-04-03 02:26:39 Functions: 70.0 % 10 7

            Line data    Source code
       1              : /**
       2              :  * @file Engine.h
       3              :  * @brief Containing class for all game engine management.
       4              :  *
       5              :  * Game engine management.
       6              :  */
       7              : #ifndef _ENGINE_H_
       8              : #define _ENGINE_H_
       9              : 
      10              : #include <GL/glut.h>
      11              : #include <AL/alc.h>
      12              : #include <string>
      13              : 
      14              : #include "SoundFX.h"
      15              : #include "gametimer.h"
      16              : #include "KeyState.h"
      17              : #include "GameLevel.h"
      18              : #include "TextGameObject.h"
      19              : 
      20              : extern "C" {
      21              :   #include "luajit-2.1/lua.h"
      22              :   #include "luajit-2.1/lualib.h"
      23              :   #include "luajit-2.1/lauxlib.h"
      24              : }
      25              : 
      26              : class Engine {
      27              :   public:
      28              :     Engine();
      29              :     ~Engine();
      30              : 
      31              :     void gameCycle();
      32              :     void prepare();
      33              :     void initGL();
      34              :     void initAL();
      35              :     void loadSoundFx();
      36              :     void unloadSoundFx();
      37              : 
      38              :     void processKeyUp(const int& key);
      39              :     void processKeyDown(const int& key);
      40              :     void processCommands();
      41              :     void processNormalKeyUp(const unsigned char& key);
      42              :     void processNormalKeyDown(const unsigned char& key);
      43              : 
      44            5 :     KeyState* getKeyState()        { return &keyState_; }
      45            5 :     KeyState* getSpecialKeyState() { return &specialKeyState_; }
      46              : 
      47              :     void processMouseMove(const int& x, const int& y);
      48            2 :     float getMouseX() { return mouseX_; }
      49            2 :     float getMouseY() { return mouseY_; }
      50              : 
      51              :     void loadLevel(const char*);
      52              :     void loadLevelFromBuffer(const char*);
      53              : 
      54              :     bool loadGame(const std::string&);
      55              :     bool loadIntroCredits();
      56              : 
      57              :     void updateGame(const float&);
      58              :     void unloadGame();
      59              :     void unload();
      60              : 
      61              :     void shutdown();
      62              :     void pause();
      63              : 
      64            1 :     float getFps() { return fps_; }
      65              : 
      66              :     void loadModels();
      67              :     void loadTextures();
      68              : 
      69            0 :     void renderText(const char* s, const float &x, const float &y) {
      70            0 :       glRasterPos2f (x, y);
      71            0 :       TextGameObject::render_string(GLUT_BITMAP_HELVETICA_18, s);
      72            0 :     }
      73              : 
      74            0 :     SoundFX* getSoundFxClass() { return &soundFx_; }
      75            2 :     bool getIsRunning()        { return isRunning_; }
      76              : 
      77            1 :     GameLevel* getCurrentLevel() { return currentLevel_; }
      78              : 
      79            0 :     void swapLevel() {
      80            0 :       GameLevel *temp = currentLevel_;
      81            0 :       currentLevel_   = storedLevel_;
      82            0 :       storedLevel_    = temp;
      83            0 :     }
      84              : 
      85              :     bool loadPng(const char*, unsigned char**, unsigned int*, unsigned int*, unsigned int*);
      86              : 
      87              : #if EDIT
      88              :     void getTerrainInfo(int &x, int &z, float &height, int &type, float &red, float &green, float &blue);
      89              :     void updateTerrain(int &x, int &z, float &height, int &type, float &red, float &green, float &blue);
      90              : 
      91              :     void updateColor(float &red, float &green, float &blue);
      92              : 
      93              :     void setMouseX(float mouseX) { mouseX_ = mouseX; }
      94              :     void setMouseY(float mouseY) { mouseY_ = mouseY; }
      95              : #endif
      96              : 
      97              :   private:
      98              :     GameLevel *currentLevel_, *storedLevel_;
      99              :     Camera *mainCamera_, *c1_, *c2_, *c3_, *c4_;
     100              :     KeyState keyState_, specialKeyState_;
     101              : 
     102              :     SoundFX soundFx_;
     103              :     ALCdevice *alcDevice_;
     104              :     ALCcontext *alcContext_;
     105              : 
     106              :     GameTimer timer_;   // game's timer
     107              :     float timeElapsed_; // time elapsed in game
     108              :     float fps_;
     109              : 
     110              :     lua_State* luaState_;
     111              : 
     112              :     bool isRunning_, isIntroRunning_, isPaused_;
     113              : 
     114              :     float mouseX_, mouseY_;
     115              : 
     116              :     // Used through game for cel shading
     117              :     GLuint shaderTexture_[1];
     118              :     unsigned int lists_; // lists used for rendering
     119              : 
     120              :     void prepLevelLoad();
     121              : 
     122              : #if EDIT
     123              :     // Mouse control values
     124              :     float lastX, lastY;
     125              : 
     126              :     // Terrain editing values
     127              :     int last_x, last_z, last_type;
     128              :     float last_height;
     129              :     float last_red, last_green, last_blue;
     130              :     bool paint, paintColor;
     131              : #endif
     132              : };
     133              : 
     134              : #endif
        

Generated by: LCOV version 2.4-0