[COMMENTS] added some comments for all the scene files
the only thing i could not find was the on key method, the other params are empty(thus no comments)
This commit is contained in:
@@ -14,7 +14,9 @@
|
|||||||
|
|
||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* sets up the first things when the objects has been made
|
||||||
|
*/
|
||||||
In_Game_Scene::In_Game_Scene()
|
In_Game_Scene::In_Game_Scene()
|
||||||
{
|
{
|
||||||
camera = new entities::Camera(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0));
|
camera = new entities::Camera(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0));
|
||||||
@@ -26,7 +28,9 @@ namespace scene
|
|||||||
gui_shader = new shaders::GuiShader();
|
gui_shader = new shaders::GuiShader();
|
||||||
gui_shader->Init();
|
gui_shader->Init();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* deletes certain veriables when the object will be deleted, prevents memory leaks
|
||||||
|
*/
|
||||||
In_Game_Scene::~In_Game_Scene()
|
In_Game_Scene::~In_Game_Scene()
|
||||||
{
|
{
|
||||||
delete camera;
|
delete camera;
|
||||||
@@ -34,7 +38,9 @@ namespace scene
|
|||||||
delete gui_shader;
|
delete gui_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts the game scene, calls the render and update methods in a while loop
|
||||||
|
*/
|
||||||
scene::Scenes scene::In_Game_Scene::start(GLFWwindow* window)
|
scene::Scenes scene::In_Game_Scene::start(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
raw_model = render_engine::LoadObjModel("res/House.obj");
|
raw_model = render_engine::LoadObjModel("res/House.obj");
|
||||||
@@ -87,8 +93,11 @@ namespace scene
|
|||||||
});
|
});
|
||||||
pause_guis.push_back(&pause_button_quit);
|
pause_guis.push_back(&pause_button_quit);
|
||||||
|
|
||||||
|
|
||||||
|
//the scene loop, this while loop represent the scene
|
||||||
while (return_value == scene::Scenes::INGAME)
|
while (return_value == scene::Scenes::INGAME)
|
||||||
{
|
{
|
||||||
|
//checks the current game state, so it can render the correct models for each state
|
||||||
switch (game_state)
|
switch (game_state)
|
||||||
{
|
{
|
||||||
/*case scene::Game_State::IDLE:
|
/*case scene::Game_State::IDLE:
|
||||||
@@ -120,11 +129,14 @@ namespace scene
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* renders the game models
|
||||||
|
*/
|
||||||
void scene::In_Game_Scene::render()
|
void scene::In_Game_Scene::render()
|
||||||
{
|
{
|
||||||
// Render
|
// Render
|
||||||
render_engine::renderer::Prepare();
|
render_engine::renderer::Prepare();
|
||||||
|
//starts the shader and begins to render
|
||||||
shader->Start();
|
shader->Start();
|
||||||
shader->LoadSkyColor(render_engine::renderer::SKY_COLOR);
|
shader->LoadSkyColor(render_engine::renderer::SKY_COLOR);
|
||||||
shader->LoadLights(lights);
|
shader->LoadLights(lights);
|
||||||
@@ -143,11 +155,19 @@ namespace scene
|
|||||||
shader->Stop();
|
shader->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//updates certain variables
|
||||||
void scene::In_Game_Scene::update(GLFWwindow* window)
|
void scene::In_Game_Scene::update(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
camera->Move(window);
|
camera->Move(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//renders the models for the pause menu
|
||||||
|
void In_Game_Scene::render_pause_menu()
|
||||||
|
{
|
||||||
|
render_engine::renderer::Render(pause_guis, *gui_shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
//manages the key input in the game scene
|
||||||
void scene::In_Game_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods)
|
void scene::In_Game_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
||||||
@@ -163,10 +183,4 @@ namespace scene
|
|||||||
game_state = scene::Game_State::RUNNING;
|
game_state = scene::Game_State::RUNNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void In_Game_Scene::render_pause_menu()
|
|
||||||
{
|
|
||||||
render_engine::renderer::Render(pause_guis, *gui_shader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
|
|
||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* This enum is for managing the game scene state.
|
||||||
|
* for example: when pressed on a specific button, the game will be in a paused state and nothing about the player or the speed of the game will be updated
|
||||||
|
* and the pause screen will show up.
|
||||||
|
**/
|
||||||
enum class Game_State
|
enum class Game_State
|
||||||
{
|
{
|
||||||
//IDLE,
|
//IDLE,
|
||||||
@@ -21,30 +26,75 @@ namespace scene
|
|||||||
PAUSED
|
PAUSED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class In_Game_Scene : public scene::Scene
|
class In_Game_Scene : public scene::Scene
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
//return_value is an enum that is necessary for the scene switching. Whenever this changes, the scene will change to a different scene.
|
||||||
scene::Scenes return_value = scene::Scenes::INGAME;
|
scene::Scenes return_value = scene::Scenes::INGAME;
|
||||||
|
//game_state is an enum that keeps track of the current game state. For example: is the game running(thus the user is playing the game) of is the game paused.
|
||||||
scene::Game_State game_state = scene::Game_State::RUNNING;
|
scene::Game_State game_state = scene::Game_State::RUNNING;
|
||||||
|
|
||||||
|
//entities_to_render is a list of entities, those entities will be rendered in the 3D environment.
|
||||||
std::vector<entities::Entity> entities_to_render;
|
std::vector<entities::Entity> entities_to_render;
|
||||||
|
//lights is a lost of light points in the game, for example the sun or it can be used to attach light effects to lamps.
|
||||||
std::vector<entities::Light> lights;
|
std::vector<entities::Light> lights;
|
||||||
|
|
||||||
models::RawModel raw_model;
|
models::RawModel raw_model;
|
||||||
models::ModelTexture texture;
|
models::ModelTexture texture;
|
||||||
|
//the shader that is used for rendering the models.
|
||||||
shaders::EntityShader* shader;
|
shaders::EntityShader* shader;
|
||||||
|
//the gui_shader is used of rendering the gui models (for example the pause buttons).
|
||||||
shaders::GuiShader* gui_shader;
|
shaders::GuiShader* gui_shader;
|
||||||
|
//camera is the camera view of the game scene, this camera will be behind the main character.
|
||||||
entities::Camera *camera;
|
entities::Camera *camera;
|
||||||
|
//guis is a list of all the gui components that needs to be load in the scene.
|
||||||
std::vector<gui::GuiTexture*> guis;
|
std::vector<gui::GuiTexture*> guis;
|
||||||
|
//pause_guis is a list of components that will be rendered when the game is paused.
|
||||||
std::vector<gui::GuiTexture*> pause_guis;
|
std::vector<gui::GuiTexture*> pause_guis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief renders the objects/gui models
|
||||||
|
* @param
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void render_pause_menu();
|
void render_pause_menu();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
In_Game_Scene();
|
In_Game_Scene();
|
||||||
~In_Game_Scene();
|
~In_Game_Scene();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief the method start is the start of the scene where a while loop runs, this runs the scene.
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @return Scene value that indicates in which scene the application is
|
||||||
|
*/
|
||||||
Scenes start(GLFWwindow* window) override;
|
Scenes start(GLFWwindow* window) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method renders the models for the game scene
|
||||||
|
* @param
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void render() override;
|
void render() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method updates the models/variables for the game scene
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void update(GLFWwindow* window) override;
|
void update(GLFWwindow* window) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method updates the models/variables for the game scene
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @param key this is the keycode on which key has been pressed
|
||||||
|
* @param scancode -
|
||||||
|
* @param action-
|
||||||
|
* @param mods -
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) override;
|
void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
namespace scene {
|
namespace scene {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this enum represents the scenes in the game, those wil help to keep track in which scene the game is.
|
||||||
|
*/
|
||||||
enum class Scenes
|
enum class Scenes
|
||||||
{
|
{
|
||||||
STARTUP,
|
STARTUP,
|
||||||
@@ -19,9 +22,37 @@ namespace scene {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Scene() = 0;
|
virtual ~Scene() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief the method start is the start of a scene where a while loop runs, this runs the scene.
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @return Scene value that indicates in which scene the application is
|
||||||
|
*/
|
||||||
virtual Scenes start(GLFWwindow* window) = 0;
|
virtual Scenes start(GLFWwindow* window) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method renders the models for a scene
|
||||||
|
* @param
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
virtual void render() = 0;
|
virtual void render() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method updates the models/variables for a scene
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
virtual void update(GLFWwindow* window) = 0;
|
virtual void update(GLFWwindow* window) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method updates the models/variables for a scene
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @param key this is the keycode on which key has been pressed
|
||||||
|
* @param scancode -
|
||||||
|
* @param action-
|
||||||
|
* @param mods -
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
virtual void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) {};
|
virtual void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,17 @@
|
|||||||
|
|
||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* deletes certain variables to prevent memory leaks
|
||||||
|
*/
|
||||||
Startup_Scene::~Startup_Scene()
|
Startup_Scene::~Startup_Scene()
|
||||||
{
|
{
|
||||||
std::cout << "startup scene gone!" << std::endl;
|
std::cout << "startup scene gone!" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts the start-up scene, calls the render and update methods in a while loop
|
||||||
|
*/
|
||||||
scene::Scenes scene::Startup_Scene::start(GLFWwindow *window)
|
scene::Scenes scene::Startup_Scene::start(GLFWwindow *window)
|
||||||
{
|
{
|
||||||
while (return_value == scene::Scenes::STARTUP)
|
while (return_value == scene::Scenes::STARTUP)
|
||||||
@@ -25,16 +31,25 @@ namespace scene
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* renders the models in the start-up scene
|
||||||
|
*/
|
||||||
void scene::Startup_Scene::render()
|
void scene::Startup_Scene::render()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the variables for the start-up scene
|
||||||
|
*/
|
||||||
void scene::Startup_Scene::update(GLFWwindow* window)
|
void scene::Startup_Scene::update(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* manages the key input in the start-up scene
|
||||||
|
*/
|
||||||
void scene::Startup_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods)
|
void scene::Startup_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
||||||
|
|||||||
@@ -9,13 +9,42 @@ namespace scene
|
|||||||
class Startup_Scene : public scene::Scene
|
class Startup_Scene : public scene::Scene
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
//return_value is an enum that is necessary for the scene switching. Whenever this changes, the scene will change to a different scene.
|
||||||
scene::Scenes return_value = scene::Scenes::STARTUP;
|
scene::Scenes return_value = scene::Scenes::STARTUP;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Startup_Scene();
|
~Startup_Scene();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief the method start is the start of the start-up scene where a while loop runs, this runs the scene.
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @return Scene value that indicates in which scene the application is
|
||||||
|
*/
|
||||||
Scenes start(GLFWwindow* window) override;
|
Scenes start(GLFWwindow* window) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method renders the models for the start-up scene
|
||||||
|
* @param
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void render() override;
|
void render() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method updates the models/variables for the start-up scene
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void update(GLFWwindow* window) override;
|
void update(GLFWwindow* window) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief this method updates the models/variables for the start-up scene
|
||||||
|
* @param window the main window of the application
|
||||||
|
* @param key this is the keycode on which key has been pressed
|
||||||
|
* @param scancode -
|
||||||
|
* @param action-
|
||||||
|
* @param mods -
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) override;
|
void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user