mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-01 09:45:42 +00:00
adding lonely option for shaders and adding a BombExplosionShaderComponent.cpp to save data
This commit is contained in:
+131
-131
@@ -18,137 +18,137 @@ if (EMSCRIPTEN)
|
||||
endif ()
|
||||
|
||||
set(SOURCES
|
||||
sources/Models/GameState.hpp
|
||||
sources/Runner/Runner.cpp
|
||||
sources/Runner/Runner.hpp
|
||||
sources/Map/Map.cpp
|
||||
sources/Map/Map.hpp
|
||||
sources/Items/Bonus.cpp
|
||||
sources/Items/Bonus.hpp
|
||||
sources/Component/Position/PositionComponent.cpp
|
||||
sources/Component/Position/PositionComponent.hpp
|
||||
sources/Component/Movable/MovableComponent.cpp
|
||||
sources/Component/Movable/MovableComponent.hpp
|
||||
sources/Component/Controllable/ControllableComponent.hpp
|
||||
sources/Component/Controllable/ControllableComponent.cpp
|
||||
sources/Component/BombHolder/BombHolderComponent.cpp
|
||||
sources/Component/BombHolder/BombHolderComponent.hpp
|
||||
sources/Component/Gamepad/GamepadComponent.cpp
|
||||
sources/Component/Gamepad/GamepadComponent.hpp
|
||||
sources/Component/Keyboard/KeyboardComponent.cpp
|
||||
sources/Component/Keyboard/KeyboardComponent.hpp
|
||||
sources/Component/Health/HealthComponent.cpp
|
||||
sources/Component/Health/HealthComponent.hpp
|
||||
sources/System/Movable/MovableSystem.hpp
|
||||
sources/System/Movable/MovableSystem.cpp
|
||||
sources/System/Controllable/ControllableSystem.cpp
|
||||
sources/System/Controllable/ControllableSystem.hpp
|
||||
sources/System/Gamepad/GamepadSystem.cpp
|
||||
sources/System/Gamepad/GamepadSystem.hpp
|
||||
sources/System/Health/HealthSystem.cpp
|
||||
sources/System/Health/HealthSystem.hpp
|
||||
sources/System/Keyboard/KeyboardSystem.cpp
|
||||
sources/System/Keyboard/KeyboardSystem.hpp
|
||||
sources/System/Movable/MovableSystem.cpp
|
||||
sources/System/Movable/MovableSystem.hpp
|
||||
sources/Models/Vector3.hpp
|
||||
sources/Component/GridCentered/GridCenteredComponent.cpp
|
||||
sources/Component/GridCentered/GridCenteredComponent.hpp
|
||||
sources/System/GridCentered/GridCenteredSystem.cpp
|
||||
sources/System/GridCentered/GridCenteredSystem.hpp
|
||||
sources/Models/Vector2.hpp
|
||||
sources/Component/Renderer/Drawable2DComponent.hpp
|
||||
sources/Component/Renderer/Drawable3DComponent.hpp
|
||||
sources/System/Renderer/RenderSystem.hpp
|
||||
sources/System/Renderer/RenderSystem.cpp
|
||||
sources/Component/Renderer/CameraComponent.cpp
|
||||
sources/Component/Renderer/CameraComponent.hpp
|
||||
sources/System/BombHolder/BombHolderSystem.cpp
|
||||
sources/System/BombHolder/BombHolderSystem.hpp
|
||||
sources/Component/Timer/TimerComponent.cpp
|
||||
sources/Component/Timer/TimerComponent.hpp
|
||||
sources/System/Timer/TimerSystem.cpp
|
||||
sources/System/Timer/TimerSystem.hpp
|
||||
sources/System/Event/EventSystem.cpp
|
||||
sources/System/Event/EventSystem.hpp
|
||||
sources/Component/Animation/AnimationsComponent.cpp
|
||||
sources/Component/Animation/AnimationsComponent.hpp
|
||||
sources/System/Animation/AnimationsSystem.cpp
|
||||
sources/System/Animation/AnimationsSystem.hpp
|
||||
sources/Component/Collision/CollisionComponent.cpp
|
||||
sources/Component/Collision/CollisionComponent.hpp
|
||||
sources/System/Collision/CollisionSystem.hpp
|
||||
sources/System/Collision/CollisionSystem.cpp
|
||||
sources/Component/Button/ButtonComponent.hpp
|
||||
sources/System/MenuControllable/MenuControllableSystem.cpp
|
||||
sources/System/MenuControllable/MenuControllableSystem.hpp
|
||||
sources/System/Levitate/LevitateSystem.hpp
|
||||
sources/System/Levitate/LevitateSystem.cpp
|
||||
sources/Component/Levitate/LevitateComponent.cpp
|
||||
sources/Component/Levitate/LevitateComponent.cpp
|
||||
sources/Component/Animator/AnimatorComponent.cpp
|
||||
sources/Component/Animator/AnimatorComponent.hpp
|
||||
sources/System/Animator/AnimatorSystem.cpp
|
||||
sources/System/Animator/AnimatorSystem.hpp
|
||||
sources/Component/Shaders/ShaderComponent.cpp
|
||||
sources/Component/Shaders/ShaderComponent.hpp
|
||||
sources/Component/Bomb/BasicBombComponent.cpp
|
||||
sources/Component/Bomb/BasicBombComponent.hpp
|
||||
sources/Component/Bonus/PlayerBonusComponent.hpp
|
||||
sources/Component/Bonus/PlayerBonusComponent.cpp
|
||||
sources/System/Bonus/PlayerBonusSystem.hpp
|
||||
sources/System/Bonus/PlayerBonusSystem.cpp
|
||||
sources/Component/Tag/TagComponent.hpp
|
||||
sources/Component/Music/MusicComponent.cpp
|
||||
sources/Component/Music/MusicComponent.hpp
|
||||
sources/Component/Sound/SoundComponent.hpp
|
||||
sources/Component/Sound/SoundComponent.cpp
|
||||
sources/System/Sound/MenuSoundManagerSystem.cpp
|
||||
sources/System/Sound/MenuSoundManagerSystem.hpp
|
||||
sources/System/Sound/PlayerSoundManagerSystem.cpp
|
||||
sources/System/Sound/PlayerSoundManagerSystem.hpp
|
||||
sources/System/Music/MusicSystem.hpp
|
||||
sources/System/Music/MusicSystem.cpp
|
||||
sources/System/Lobby/LobbySystem.cpp
|
||||
sources/System/Lobby/LobbySystem.hpp
|
||||
sources/Component/Lobby/LobbyComponent.cpp
|
||||
sources/Component/Lobby/LobbyComponent.hpp
|
||||
sources/Component/Gravity/GravityComponent.hpp
|
||||
sources/Component/Gravity/GravityComponent.cpp
|
||||
sources/System/Gravity/GravitySystem.hpp
|
||||
sources/System/Gravity/GravitySystem.cpp
|
||||
sources/Component/BumperTimer/BumperTimerComponent.hpp
|
||||
sources/Component/BumperTimer/BumperTimerComponent.cpp
|
||||
sources/System/BumperTimer/BumperTimerSystem.hpp
|
||||
sources/System/BumperTimer/BumperTimerSystem.cpp
|
||||
sources/System/Bomb/BombSystem.cpp
|
||||
sources/System/Bomb/BombSystem.hpp
|
||||
sources/Component/IntroAnimation/IntroAnimationComponent.hpp
|
||||
sources/Component/IntroAnimation/IntroAnimationComponent.cpp
|
||||
sources/System/IntroAnimation/IntroAnimationSystem.hpp
|
||||
sources/System/IntroAnimation/IntroAnimationSystem.cpp
|
||||
sources/Runner/SplashScreenScene.cpp
|
||||
sources/Runner/TitleScreenScene.cpp
|
||||
sources/Runner/MainMenuScene.cpp
|
||||
sources/Runner/GameScene.cpp
|
||||
sources/Runner/PauseMenuScene.cpp
|
||||
sources/Runner/SettingsMenuScene.cpp
|
||||
sources/Runner/CreditScene.cpp
|
||||
sources/Component/Score/ScoreComponent.cpp
|
||||
sources/Component/Score/ScoreComponent.hpp
|
||||
sources/System/Score/ScoreSystem.cpp
|
||||
sources/System/Score/ScoreSystem.hpp
|
||||
sources/System/EndCondition/EndConditionSystem.hpp
|
||||
sources/System/EndCondition/EndConditionSystem.cpp
|
||||
sources/Runner/LobbyScene.cpp
|
||||
sources/Runner/ScoreScene.cpp
|
||||
sources/System/Shaders/ShaderSystem.cpp
|
||||
sources/System/Shaders/ShaderSystem.hpp
|
||||
sources/System/Shaders/ShaderModelSystem.cpp
|
||||
sources/System/Shaders/ShaderModelSystem.hpp
|
||||
sources/System/Shaders/ShaderDrawable2DSystem.cpp
|
||||
sources/System/Shaders/ShaderDrawable2DSystem.hpp
|
||||
)
|
||||
sources/Models/GameState.hpp
|
||||
sources/Runner/Runner.cpp
|
||||
sources/Runner/Runner.hpp
|
||||
sources/Map/Map.cpp
|
||||
sources/Map/Map.hpp
|
||||
sources/Items/Bonus.cpp
|
||||
sources/Items/Bonus.hpp
|
||||
sources/Component/Position/PositionComponent.cpp
|
||||
sources/Component/Position/PositionComponent.hpp
|
||||
sources/Component/Movable/MovableComponent.cpp
|
||||
sources/Component/Movable/MovableComponent.hpp
|
||||
sources/Component/Controllable/ControllableComponent.hpp
|
||||
sources/Component/Controllable/ControllableComponent.cpp
|
||||
sources/Component/BombHolder/BombHolderComponent.cpp
|
||||
sources/Component/BombHolder/BombHolderComponent.hpp
|
||||
sources/Component/Gamepad/GamepadComponent.cpp
|
||||
sources/Component/Gamepad/GamepadComponent.hpp
|
||||
sources/Component/Keyboard/KeyboardComponent.cpp
|
||||
sources/Component/Keyboard/KeyboardComponent.hpp
|
||||
sources/Component/Health/HealthComponent.cpp
|
||||
sources/Component/Health/HealthComponent.hpp
|
||||
sources/System/Movable/MovableSystem.hpp
|
||||
sources/System/Movable/MovableSystem.cpp
|
||||
sources/System/Controllable/ControllableSystem.cpp
|
||||
sources/System/Controllable/ControllableSystem.hpp
|
||||
sources/System/Gamepad/GamepadSystem.cpp
|
||||
sources/System/Gamepad/GamepadSystem.hpp
|
||||
sources/System/Health/HealthSystem.cpp
|
||||
sources/System/Health/HealthSystem.hpp
|
||||
sources/System/Keyboard/KeyboardSystem.cpp
|
||||
sources/System/Keyboard/KeyboardSystem.hpp
|
||||
sources/System/Movable/MovableSystem.cpp
|
||||
sources/System/Movable/MovableSystem.hpp
|
||||
sources/Models/Vector3.hpp
|
||||
sources/Component/GridCentered/GridCenteredComponent.cpp
|
||||
sources/Component/GridCentered/GridCenteredComponent.hpp
|
||||
sources/System/GridCentered/GridCenteredSystem.cpp
|
||||
sources/System/GridCentered/GridCenteredSystem.hpp
|
||||
sources/Models/Vector2.hpp
|
||||
sources/Component/Renderer/Drawable2DComponent.hpp
|
||||
sources/Component/Renderer/Drawable3DComponent.hpp
|
||||
sources/System/Renderer/RenderSystem.hpp
|
||||
sources/System/Renderer/RenderSystem.cpp
|
||||
sources/Component/Renderer/CameraComponent.cpp
|
||||
sources/Component/Renderer/CameraComponent.hpp
|
||||
sources/System/BombHolder/BombHolderSystem.cpp
|
||||
sources/System/BombHolder/BombHolderSystem.hpp
|
||||
sources/Component/Timer/TimerComponent.cpp
|
||||
sources/Component/Timer/TimerComponent.hpp
|
||||
sources/System/Timer/TimerSystem.cpp
|
||||
sources/System/Timer/TimerSystem.hpp
|
||||
sources/System/Event/EventSystem.cpp
|
||||
sources/System/Event/EventSystem.hpp
|
||||
sources/Component/Animation/AnimationsComponent.cpp
|
||||
sources/Component/Animation/AnimationsComponent.hpp
|
||||
sources/System/Animation/AnimationsSystem.cpp
|
||||
sources/System/Animation/AnimationsSystem.hpp
|
||||
sources/Component/Collision/CollisionComponent.cpp
|
||||
sources/Component/Collision/CollisionComponent.hpp
|
||||
sources/System/Collision/CollisionSystem.hpp
|
||||
sources/System/Collision/CollisionSystem.cpp
|
||||
sources/Component/Button/ButtonComponent.hpp
|
||||
sources/System/MenuControllable/MenuControllableSystem.cpp
|
||||
sources/System/MenuControllable/MenuControllableSystem.hpp
|
||||
sources/System/Levitate/LevitateSystem.hpp
|
||||
sources/System/Levitate/LevitateSystem.cpp
|
||||
sources/Component/Levitate/LevitateComponent.cpp
|
||||
sources/Component/Levitate/LevitateComponent.cpp
|
||||
sources/Component/Animator/AnimatorComponent.cpp
|
||||
sources/Component/Animator/AnimatorComponent.hpp
|
||||
sources/System/Animator/AnimatorSystem.cpp
|
||||
sources/System/Animator/AnimatorSystem.hpp
|
||||
sources/Component/Shaders/ShaderComponent.cpp
|
||||
sources/Component/Shaders/ShaderComponent.hpp
|
||||
sources/Component/Bomb/BasicBombComponent.cpp
|
||||
sources/Component/Bomb/BasicBombComponent.hpp
|
||||
sources/Component/Bonus/PlayerBonusComponent.hpp
|
||||
sources/Component/Bonus/PlayerBonusComponent.cpp
|
||||
sources/System/Bonus/PlayerBonusSystem.hpp
|
||||
sources/System/Bonus/PlayerBonusSystem.cpp
|
||||
sources/Component/Tag/TagComponent.hpp
|
||||
sources/Component/Music/MusicComponent.cpp
|
||||
sources/Component/Music/MusicComponent.hpp
|
||||
sources/Component/Sound/SoundComponent.hpp
|
||||
sources/Component/Sound/SoundComponent.cpp
|
||||
sources/System/Sound/MenuSoundManagerSystem.cpp
|
||||
sources/System/Sound/MenuSoundManagerSystem.hpp
|
||||
sources/System/Sound/PlayerSoundManagerSystem.cpp
|
||||
sources/System/Sound/PlayerSoundManagerSystem.hpp
|
||||
sources/System/Music/MusicSystem.hpp
|
||||
sources/System/Music/MusicSystem.cpp
|
||||
sources/System/Lobby/LobbySystem.cpp
|
||||
sources/System/Lobby/LobbySystem.hpp
|
||||
sources/Component/Lobby/LobbyComponent.cpp
|
||||
sources/Component/Lobby/LobbyComponent.hpp
|
||||
sources/Component/Gravity/GravityComponent.hpp
|
||||
sources/Component/Gravity/GravityComponent.cpp
|
||||
sources/System/Gravity/GravitySystem.hpp
|
||||
sources/System/Gravity/GravitySystem.cpp
|
||||
sources/Component/BumperTimer/BumperTimerComponent.hpp
|
||||
sources/Component/BumperTimer/BumperTimerComponent.cpp
|
||||
sources/System/BumperTimer/BumperTimerSystem.hpp
|
||||
sources/System/BumperTimer/BumperTimerSystem.cpp
|
||||
sources/System/Bomb/BombSystem.cpp
|
||||
sources/System/Bomb/BombSystem.hpp
|
||||
sources/Component/IntroAnimation/IntroAnimationComponent.hpp
|
||||
sources/Component/IntroAnimation/IntroAnimationComponent.cpp
|
||||
sources/System/IntroAnimation/IntroAnimationSystem.hpp
|
||||
sources/System/IntroAnimation/IntroAnimationSystem.cpp
|
||||
sources/Runner/SplashScreenScene.cpp
|
||||
sources/Runner/TitleScreenScene.cpp
|
||||
sources/Runner/MainMenuScene.cpp
|
||||
sources/Runner/GameScene.cpp
|
||||
sources/Runner/PauseMenuScene.cpp
|
||||
sources/Runner/SettingsMenuScene.cpp
|
||||
sources/Runner/CreditScene.cpp
|
||||
sources/Component/Score/ScoreComponent.cpp
|
||||
sources/Component/Score/ScoreComponent.hpp
|
||||
sources/System/Score/ScoreSystem.cpp
|
||||
sources/System/Score/ScoreSystem.hpp
|
||||
sources/System/EndCondition/EndConditionSystem.hpp
|
||||
sources/System/EndCondition/EndConditionSystem.cpp
|
||||
sources/Runner/LobbyScene.cpp
|
||||
sources/Runner/ScoreScene.cpp
|
||||
sources/System/Shaders/ShaderSystem.cpp
|
||||
sources/System/Shaders/ShaderSystem.hpp
|
||||
sources/System/Shaders/ShaderModelSystem.cpp
|
||||
sources/System/Shaders/ShaderModelSystem.hpp
|
||||
sources/System/Shaders/ShaderDrawable2DSystem.cpp
|
||||
sources/System/Shaders/ShaderDrawable2DSystem.hpp
|
||||
sources/Component/Shaders/Items/BombExplosionShaderComponent.cpp sources/Component/Shaders/Items/BombExplosionShaderComponent.hpp)
|
||||
add_executable(bomberman
|
||||
sources/main.cpp
|
||||
${SOURCES}
|
||||
|
||||
@@ -89,9 +89,11 @@ attribute vec4 vertexColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform int frame;
|
||||
uniform float frame;
|
||||
uniform vec3 center;
|
||||
|
||||
uniform float radius;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec3 fragPosition;
|
||||
|
||||
@@ -101,6 +103,6 @@ void main() {
|
||||
// Send vertex attributes to fragment shader
|
||||
fragPosition = vertexPosition + vertexPosition * vec3(cnoise(vec3(vertexNormal + vec3(frame))) * 0.5);
|
||||
// Calculate final vertex position
|
||||
gl_Position = mvp * vec4(fragPosition , 1.0);
|
||||
gl_Position = mvp * vec4(fragPosition , radius);
|
||||
//gl_Position = vec4(vertexNormal, 1.0);
|
||||
}
|
||||
@@ -12,10 +12,10 @@ namespace RAY
|
||||
Cache<::Shader> Shader::_shadersCache(LoadShader, UnloadShader);
|
||||
|
||||
|
||||
Shader::Shader(const std::string &vertexFile, const std::string &fragmentFile)
|
||||
Shader::Shader(const std::string &vertexFile, const std::string &fragmentFile, bool lonely)
|
||||
: _vertexFile(vertexFile),
|
||||
_fragmentFile(fragmentFile),
|
||||
_rayLibShader(_shadersCache.fetch(vertexFile, fragmentFile))
|
||||
_rayLibShader(_shadersCache.fetch(vertexFile, fragmentFile, lonely))
|
||||
{
|
||||
this->_rayLibShader->locs[SHADER_LOC_MAP_EMISSION] = GetShaderLocation(*this->_rayLibShader, "mask");
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace RAY
|
||||
void setLocation(::ShaderLocationIndex, const std::string &name);
|
||||
|
||||
//! @brief ctor if no vertexfile in needed set it to nullptr
|
||||
Shader(const std::string &vertexFile, const std::string &fragmentFile);
|
||||
Shader(const std::string &vertexFile, const std::string &fragmentFile, bool lonely = false);
|
||||
//! @brief Default copy ctor
|
||||
Shader(const Shader &) = default;
|
||||
//! @brief dtor
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace RAY {
|
||||
this->_cache.emplace(path, std::vector<std::shared_ptr<T>>());
|
||||
std::vector<std::shared_ptr<T>> &matchingDataVector = this->_cache.at(path);
|
||||
|
||||
if (matchingDataVector.size()) {
|
||||
if (!matchingDataVector.empty()) {
|
||||
for (std::shared_ptr<T> &i: matchingDataVector) {
|
||||
if (!lonely)
|
||||
return i;
|
||||
@@ -117,23 +117,34 @@ namespace RAY {
|
||||
_dataLoader(std::move(dataLoader)), _dataUnloader(std::move(dataUnloader))
|
||||
{};
|
||||
|
||||
std::shared_ptr<::Shader> fetch(const std::string &vertexFile, const std::string &fragmentFile)
|
||||
std::shared_ptr<::Shader> fetch(const std::string &vertexFile, const std::string &fragmentFile, bool lonely = false)
|
||||
{
|
||||
const std::string index = vertexFile + fragmentFile;
|
||||
|
||||
if (vertexFile.empty() && fragmentFile.empty()) {
|
||||
throw RAY::Exception::WrongInputError();
|
||||
}
|
||||
if (this->_cache.find(index) != this->_cache.end())
|
||||
return this->_cache[index];
|
||||
if (!this->_cache.contains(index)) {
|
||||
this->_cache.emplace(index, std::vector<std::shared_ptr<::Shader>>());
|
||||
}
|
||||
std::vector<std::shared_ptr<::Shader>> &matchingDataVector = this->_cache.at(index);
|
||||
|
||||
this->_cache.emplace(index, std::shared_ptr<::Shader>(
|
||||
if (!matchingDataVector.empty()) {
|
||||
for (std::shared_ptr<::Shader> &i: matchingDataVector) {
|
||||
if (!lonely)
|
||||
return i;
|
||||
if (lonely && i.use_count() == 1)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
matchingDataVector.emplace_back(std::shared_ptr<::Shader>(
|
||||
new ::Shader(
|
||||
this->_dataLoader(vertexFile.empty() ? nullptr : vertexFile.c_str(), fragmentFile.c_str())),
|
||||
[this](::Shader *p) {
|
||||
this->_dataUnloader(*p);
|
||||
}));
|
||||
return this->_cache[index];
|
||||
return matchingDataVector.back();
|
||||
};
|
||||
private:
|
||||
//! @brief function to call to load data
|
||||
@@ -143,6 +154,6 @@ namespace RAY {
|
||||
std::function<void(::Shader)> _dataUnloader;
|
||||
|
||||
//! @brief map storing shared ptr of caches
|
||||
std::unordered_map<std::string, std::shared_ptr<::Shader>> _cache;
|
||||
std::unordered_map<std::string, std::vector<std::shared_ptr<::Shader>>> _cache;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Created by cbihan on 16/06/2021.
|
||||
//
|
||||
|
||||
#include "BombExplosionShaderComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
|
||||
BombExplosionShaderComponent::BombExplosionShaderComponent(WAL::Entity &entity) :
|
||||
Component(entity)
|
||||
{
|
||||
}
|
||||
|
||||
WAL::Component *BombExplosionShaderComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new BombExplosionShaderComponent(this->_entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Created by cbihan on 16/06/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Component/Component.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
class BombExplosionShaderComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
//! @brief Explosion radius
|
||||
float explosionRadius = 4;
|
||||
//! @brief to have the shader move by the time
|
||||
float frameCounter = 0;
|
||||
|
||||
//! @brief The clock to use
|
||||
std::chrono::nanoseconds clock = 0ns;
|
||||
|
||||
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
|
||||
//! @brief ctor
|
||||
explicit BombExplosionShaderComponent(WAL::Entity &entity);
|
||||
|
||||
//! @brief Default copy ctor
|
||||
BombExplosionShaderComponent(const BombExplosionShaderComponent &) = default;
|
||||
|
||||
//! @brief Default dtor
|
||||
~BombExplosionShaderComponent() override = default;
|
||||
|
||||
//! @brief Default assignment operator
|
||||
BombExplosionShaderComponent &operator=(const BombExplosionShaderComponent &) = delete;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -22,9 +22,10 @@ namespace BBM
|
||||
ShaderComponent::ShaderComponent(WAL::Entity &entity,
|
||||
const std::string &fragmentFilePath,
|
||||
const std::string &vertexFilePath,
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate)
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate,
|
||||
bool lonely)
|
||||
: WAL::Component(entity),
|
||||
shader(vertexFilePath, fragmentFilePath),
|
||||
shader(vertexFilePath, fragmentFilePath, lonely),
|
||||
fragmentFilePath(fragmentFilePath),
|
||||
vertexFilePath(vertexFilePath),
|
||||
update(onFixedUpdate)
|
||||
@@ -44,8 +45,9 @@ namespace BBM
|
||||
ShaderComponentModel::ShaderComponentModel(WAL::Entity &entity,
|
||||
const std::string &fragmentFilePath,
|
||||
const std::string &vertexFilePath,
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate)
|
||||
: ShaderComponent(entity, fragmentFilePath, vertexFilePath, onFixedUpdate)
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate,
|
||||
bool lonely)
|
||||
: ShaderComponent(entity, fragmentFilePath, vertexFilePath, onFixedUpdate, lonely)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,8 +62,9 @@ namespace BBM
|
||||
ShaderComponentDrawable2D::ShaderComponentDrawable2D(WAL::Entity &entity,
|
||||
const std::string &fragmentFilePath,
|
||||
const std::string &vertexFilePath,
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate)
|
||||
: ShaderComponent(entity, fragmentFilePath, vertexFilePath, onFixedUpdate)
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate,
|
||||
bool lonely)
|
||||
: ShaderComponent(entity, fragmentFilePath, vertexFilePath, onFixedUpdate, lonely)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,8 @@ namespace BBM
|
||||
ShaderComponent(WAL::Entity &entity,
|
||||
const std::string &fragmentFilePath,
|
||||
const std::string &vertexFilePath = "",
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate = WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds>());
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate = WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds>(),
|
||||
bool lonely = false);
|
||||
|
||||
//! @brief Default copy ctor
|
||||
ShaderComponent(const ShaderComponent &) = default;
|
||||
@@ -70,7 +71,8 @@ namespace BBM
|
||||
ShaderComponentModel(WAL::Entity &entity,
|
||||
const std::string &fragmentFilePath,
|
||||
const std::string &vertexFilePath = "",
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate = WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds>());
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate = WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds>(),
|
||||
bool lonely = false);
|
||||
|
||||
//! @brief Default copy ctor
|
||||
ShaderComponentModel(const ShaderComponentModel &) = default;
|
||||
@@ -90,7 +92,8 @@ namespace BBM
|
||||
ShaderComponentDrawable2D(WAL::Entity &entity,
|
||||
const std::string &fragmentFilePath,
|
||||
const std::string &vertexFilePath = "",
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate = WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds>());
|
||||
const WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds> &onFixedUpdate = WAL::Callback<WAL::Entity &, WAL::Wal &, std::chrono::nanoseconds>(),
|
||||
bool lonely = false);
|
||||
|
||||
//! @brief Default copy ctor
|
||||
ShaderComponentDrawable2D(const ShaderComponentDrawable2D &) = default;
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
#include "Component/Health/HealthComponent.hpp"
|
||||
#include <functional>
|
||||
#include <Map/Map.hpp>
|
||||
#include "Component/Shaders/Items/BombExplosionShaderComponent.hpp"
|
||||
#include <chrono>
|
||||
#include "Component/Shaders/ShaderComponent.hpp"
|
||||
#include "Component/Collision/CollisionComponent.hpp"
|
||||
#include "Component/Tag/TagComponent.hpp"
|
||||
|
||||
int glob = 0;
|
||||
float glob = 0;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
namespace RAY3D = RAY::Drawables::Drawables3D;
|
||||
@@ -48,17 +49,22 @@ namespace BBM
|
||||
return;
|
||||
wal.getScene()->scheduleNewEntity("explosion")
|
||||
.addComponent<PositionComponent>(position)
|
||||
.addComponent<BombExplosionShaderComponent>()
|
||||
.addComponent<ShaderComponentModel>("assets/shaders/mask.fs", "assets/shaders/mask.vs", [](WAL::Entity &entity, WAL::Wal &wal, std::chrono::nanoseconds dtime) {
|
||||
static std::chrono::nanoseconds nanoseconds {};
|
||||
auto &ctx = entity.getComponent<BombExplosionShaderComponent>();
|
||||
auto &shader = entity.getComponent<ShaderComponentModel>();
|
||||
|
||||
nanoseconds += dtime;
|
||||
if (duration_cast<std::chrono::milliseconds>(nanoseconds).count() <= 400)
|
||||
ctx.clock += dtime;
|
||||
if (duration_cast<std::chrono::milliseconds>(ctx.clock).count() <= 10)
|
||||
return;
|
||||
std::cout << "test" << std::endl;
|
||||
shader.shader.setShaderUniformVar("frame", glob);
|
||||
glob++;
|
||||
glob %= 40;
|
||||
ctx.clock = 0ns;
|
||||
ctx.explosionRadius -= 0.3;
|
||||
if (ctx.explosionRadius < 1.2) {
|
||||
ctx.explosionRadius = 1.2;
|
||||
}
|
||||
shader.shader.setShaderUniformVar("frame", ctx.frameCounter);
|
||||
shader.shader.setShaderUniformVar("radius", ctx.explosionRadius);
|
||||
ctx.frameCounter += 0.1;
|
||||
})
|
||||
.addComponent<TimerComponent>(500ms, [](WAL::Entity &explosion, WAL::Wal &wal) {
|
||||
explosion.scheduleDeletion();
|
||||
|
||||
Reference in New Issue
Block a user