2014-12-15 16:47:30 +01:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: GameState.hpp
|
|
|
|
*
|
2018-06-05 01:24:54 +02:00
|
|
|
* Description:
|
2014-12-15 16:47:30 +01:00
|
|
|
*
|
|
|
|
* Created: 15/12/2014 03:51:32
|
|
|
|
*
|
2018-06-12 09:24:43 +02:00
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
2014-12-15 16:47:30 +01:00
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef GAMESTATE_HPP_
|
|
|
|
#define GAMESTATE_HPP_
|
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
#include "ApplicationState.hpp"
|
2018-06-15 00:05:17 +02:00
|
|
|
#include "BlockCursor.hpp"
|
2014-12-18 07:02:48 +01:00
|
|
|
#include "Camera.hpp"
|
2018-06-14 18:24:07 +02:00
|
|
|
#include "Crosshair.hpp"
|
2018-06-20 05:43:52 +02:00
|
|
|
#include "Hotbar.hpp"
|
2014-12-26 00:39:10 +01:00
|
|
|
#include "Skybox.hpp"
|
2014-12-18 07:02:48 +01:00
|
|
|
#include "World.hpp"
|
2014-12-15 16:47:30 +01:00
|
|
|
|
2018-06-14 21:16:56 +02:00
|
|
|
#include "RenderTarget.hpp"
|
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
class GameState : public ApplicationState {
|
|
|
|
public:
|
|
|
|
GameState();
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2018-06-15 00:05:17 +02:00
|
|
|
void initShaders();
|
2018-06-14 22:11:25 +02:00
|
|
|
|
2018-06-14 02:38:02 +02:00
|
|
|
void onEvent(const SDL_Event &event) override;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2018-06-14 02:38:02 +02:00
|
|
|
void update() override;
|
|
|
|
|
2018-06-14 23:36:01 +02:00
|
|
|
float fract(float value) const;
|
|
|
|
glm::vec4 findSelectedBlock(bool useDepthBuffer) const;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
private:
|
2018-06-14 23:36:01 +02:00
|
|
|
void draw(RenderTarget &target, RenderStates states) const override;
|
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
glm::mat4 m_projectionMatrix;
|
|
|
|
glm::mat4 m_viewMatrix;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2018-06-15 00:05:17 +02:00
|
|
|
Camera &m_camera{Camera::getInstance()};
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
Shader m_shader;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-26 00:39:10 +01:00
|
|
|
Skybox m_skybox;
|
2014-12-18 07:02:48 +01:00
|
|
|
World m_world;
|
2018-06-13 21:48:35 +02:00
|
|
|
|
2018-06-15 01:13:59 +02:00
|
|
|
glm::vec4 m_selectedBlock{0, 0, 0, -1};
|
2018-06-15 00:05:17 +02:00
|
|
|
BlockCursor m_blockCursor{m_camera, m_world, m_viewMatrix, m_projectionMatrix};
|
2018-06-14 18:24:07 +02:00
|
|
|
Crosshair m_crosshair;
|
2018-06-20 05:43:52 +02:00
|
|
|
|
|
|
|
Texture m_widgetTexture;
|
2018-06-23 03:26:34 +02:00
|
|
|
Inventory m_playerInventory{9, 3};
|
|
|
|
Inventory m_hotbarInventory{9, 1};
|
|
|
|
Hotbar m_hotbar{m_hotbarInventory};
|
2014-12-15 16:47:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GAMESTATE_HPP_
|