mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-21 13:55:10 +00:00
adding a screen renderer system
This commit is contained in:
@@ -30,7 +30,7 @@ set(SOURCES
|
|||||||
add_executable(bomberman
|
add_executable(bomberman
|
||||||
sources/main.cpp
|
sources/main.cpp
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
)
|
sources/System/Renderer/RenderScreenSystem.hpp)
|
||||||
target_include_directories(bomberman PUBLIC sources)
|
target_include_directories(bomberman PUBLIC sources)
|
||||||
target_link_libraries(bomberman PUBLIC wal ray)
|
target_link_libraries(bomberman PUBLIC wal ray)
|
||||||
|
|
||||||
|
|||||||
50
sources/System/Renderer/RenderScreenSystem.hpp
Normal file
50
sources/System/Renderer/RenderScreenSystem.hpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// Created by cbihan on 26/05/2021.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "System/System.hpp"
|
||||||
|
#include "Camera/Camera2D.hpp"
|
||||||
|
#include "Window.hpp"
|
||||||
|
|
||||||
|
namespace BBM
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
class RenderScreenSystem : public WAL::System
|
||||||
|
{
|
||||||
|
//! @brief The window to render on
|
||||||
|
RAY::Window &_window;
|
||||||
|
//! @brief The camera
|
||||||
|
T &_camera;
|
||||||
|
public:
|
||||||
|
//! @brief ctor
|
||||||
|
explicit RenderScreenSystem(RAY::Window &window, T camera)
|
||||||
|
: WAL::System({typeid(RenderScreenSystem)}),
|
||||||
|
_window(window),
|
||||||
|
_camera(camera)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//! @brief A method called after all entities that this system manage has been updated.
|
||||||
|
//! @note render on screen here
|
||||||
|
void onSelfUpdate() override
|
||||||
|
{
|
||||||
|
this->_window.unuseCamera();
|
||||||
|
this->_window.setDrawingState(RAY::Window::IDLE);
|
||||||
|
this->_camera.update();
|
||||||
|
this->_window.setDrawingState(RAY::Window::DRAWING);
|
||||||
|
this->_window.clear();
|
||||||
|
this->_window.useCamera(_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! @brief Default copy ctor
|
||||||
|
RenderScreenSystem(const RenderScreenSystem &) = delete;
|
||||||
|
//! @brief Default dtor
|
||||||
|
~RenderScreenSystem() override = default;
|
||||||
|
//! @brief Default assignment operator
|
||||||
|
RenderScreenSystem &operator=(const RenderScreenSystem &) = delete;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "Model/ModelAnimations.hpp"
|
#include "Model/ModelAnimations.hpp"
|
||||||
#include "System/Renderer/Renderer3DSystem.hpp"
|
#include "System/Renderer/Renderer3DSystem.hpp"
|
||||||
#include "Component/Drawable/Drawable3DComponent.hpp"
|
#include "Component/Drawable/Drawable3DComponent.hpp"
|
||||||
|
#include "System/Renderer/RenderScreenSystem.hpp"
|
||||||
#include "Vector/Vector3.hpp"
|
#include "Vector/Vector3.hpp"
|
||||||
#include "Window.hpp"
|
#include "Window.hpp"
|
||||||
#include "TraceLog.hpp"
|
#include "TraceLog.hpp"
|
||||||
@@ -64,6 +65,8 @@ int demo()
|
|||||||
|
|
||||||
BBM::Renderer3DSystem<RAY::Drawables::Drawables3D::Circle> circleSystem(window);
|
BBM::Renderer3DSystem<RAY::Drawables::Drawables3D::Circle> circleSystem(window);
|
||||||
|
|
||||||
|
BBM::RenderScreenSystem<RAY::Camera::Camera3D> renderSystem(window, camera);
|
||||||
|
|
||||||
wal.addSystem(circleSystem);
|
wal.addSystem(circleSystem);
|
||||||
entityPlayer.addComponent(circleComponent);
|
entityPlayer.addComponent(circleComponent);
|
||||||
|
|
||||||
@@ -80,30 +83,7 @@ int demo()
|
|||||||
float y_rotation = 0;
|
float y_rotation = 0;
|
||||||
window.setFPS(60);
|
window.setFPS(60);
|
||||||
|
|
||||||
while (!window.shouldClose())
|
//wal.run();
|
||||||
{
|
|
||||||
camera.update();
|
|
||||||
|
|
||||||
if (RAY::Controller::Keyboard::isReleased(KEY_SPACE))
|
|
||||||
{
|
|
||||||
++iterator;
|
|
||||||
if (iterator == textures.end())
|
|
||||||
iterator = textures.begin();
|
|
||||||
texture.unload();
|
|
||||||
texture.load(get_full_path(*iterator));
|
|
||||||
model.setTextureToMaterial(MAP_DIFFUSE, texture);
|
|
||||||
//animations[0].incrementFrameCounter();
|
|
||||||
//model.setAnimation(animations[0]);
|
|
||||||
}
|
|
||||||
window.setDrawingState(RAY::Window::DRAWING);
|
|
||||||
window.clear();
|
|
||||||
window.useCamera(camera);
|
|
||||||
window.draw(model, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 5.0f, 5.0f, 5.0f ));
|
|
||||||
window.draw(grid);
|
|
||||||
window.unuseCamera();
|
|
||||||
window.draw(instructionText);
|
|
||||||
window.setDrawingState(RAY::Window::IDLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.close();
|
window.close();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "Component/Position/PositionComponent.hpp"
|
#include "Component/Position/PositionComponent.hpp"
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
using namespace BBM;
|
|
||||||
using namespace WAL;
|
using namespace WAL;
|
||||||
using namespace BBM;
|
using namespace BBM;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user