Commit e13c8d03 authored by Georg Schaefer's avatar Georg Schaefer
Browse files

Merge branch 'develop' into feature/rendering/deferred_shading

parents 9434e97a 638b3f59
This diff is collapsed.
......@@ -111,3 +111,19 @@ src/physics
src/physics/collision
include/input
src/input
lib/recastnavigation/DetourTileCache/Source
lib/recastnavigation/DetourTileCache/Include
lib/recastnavigation/RecastDemo/Source
include/gameplay
lib/recastnavigation/Detour/Include
lib/recastnavigation/DebugUtils/Source
lib/recastnavigation/DetourCrowd/Source
lib/recastnavigation/RecastDemo/Contrib
src/gameplay
lib/recastnavigation/Detour/Source
lib/recastnavigation/Recast/Source
lib/recastnavigation/DebugUtils/Include
lib/recastnavigation/DetourCrowd/Include
lib/recastnavigation/RecastDemo/Contrib/fastlz
lib/recastnavigation/RecastDemo/Include
lib/recastnavigation/Recast/Include
......@@ -8,3 +8,7 @@ sound_volume : 100
debug_render : false
shadow_resolution : 256
shadows : true
camX : 0
camY : -20
camZ : 32
camAngle : 50
......@@ -4,14 +4,17 @@
#include <asset/asset_manager.hpp>
#include <ecs/entity_manager.hpp>
#include <util/config_manager.hpp>
#include <util/config.hpp>
namespace gdw {
class audio;
class graphics_system;
class game_play_system;
class input;
class rendering_system;
class game_state_machine;
class physics_system;
class config;
}
namespace gdw {
......@@ -20,12 +23,14 @@ namespace gdw {
bool quit_;
gdw::asset_manager asset_manager_;
gdw::config_manager config_manager_;
std::shared_ptr<gdw::config> config;
std::unique_ptr<gdw::audio> audio_;
std::unique_ptr<gdw::graphics_system> graphics_system_;
std::unique_ptr<gdw::input> input_;
std::unique_ptr<gdw::rendering_system> rendering_system_;
std::unique_ptr<gdw::game_state_machine> game_state_machine_;
std::unique_ptr<gdw::physics_system> physics_system_;
std::unique_ptr<gdw::game_play_system> game_play_system_;
// needs to be the last one that will be destroyed
gdw::entity_manager entity_manager_;
......@@ -55,6 +60,10 @@ namespace gdw {
return *audio_;
}
gdw::config& getConfig() {
return *this->config;
}
gdw::config_manager& config_manager() noexcept {
return config_manager_;
}
......@@ -82,6 +91,10 @@ namespace gdw {
gdw::physics_system& physics_system() noexcept {
return *physics_system_;
}
gdw::game_play_system& game_play_system() noexcept {
return *game_play_system_;
}
};
}
......
......@@ -18,6 +18,7 @@ public:
protected:
engine& engine_;
unsigned long long id_;
int channel;
};
} //Namespace gdw
......
......@@ -2,11 +2,14 @@
#define __PLAY_STATE__
#include <game_state_machine/game_state.h>
#include <memory>
namespace gdw {
class entity;
class movement_component;
class level_manager;
class game_input_manager;
class play_state : public game_state {
public:
......@@ -16,12 +19,6 @@ public:
void update(float dt);
void on_enter();
void on_exit();
private:
entity* wcube_;
movement_component* wcube_move_;
entity* wcube2_;
movement_component* wcube2_move_;
};
} //Namespace gdw
......
#ifndef __GAME_INPUT_MANAGER__
#define __GAME_INPUT_MANAGER__
namespace gdw {
class engine;
class game_input_manager {
public:
game_input_manager(engine& engine);
~game_input_manager();
void update(float dt);
private:
void handle_key_input();
void handle_mouse_input();
private:
engine& engine_;
};
} //Namespace gdw
#endif
#ifndef __GAME_PLAY_SYSTEM__
#define __GAME_PLAY_SYSTEM__
#include <memory>
namespace gdw {
class level_manager;
class game_input_manager;
class engine;
class game_play_system {
public:
game_play_system(engine& engine);
~game_play_system();
void update(float dt);
gdw::level_manager& level_manager() {return *level_manager_.get();}
gdw::game_input_manager& game_input_manager() {return *game_input_manager_.get();}
private:
std::unique_ptr<gdw::level_manager> level_manager_;
std::unique_ptr<gdw::game_input_manager> game_input_manager_;
};
} //Namespace gdw
#endif
#ifndef __LEVEL_MANAGER__
#define __LEVEL_MANAGER__
#include <vector>
#include <memory>
#include <glm/glm.hpp>
namespace gdw {
class entity;
class engine;
class level_manager {
public:
level_manager(engine& engine);
~level_manager();
void build_stage();
entity* player();
entity* camera();
void create_victim(float y);
void update(float dt);
float player_speed() {return player_speed_;}
void create_asteroid(glm::vec2 pos);
private:
private:
engine& engine_;
std::vector<unsigned long long> victims_;
std::vector<unsigned long long> asteroids_;
unsigned long long player_;
unsigned long long camera_;
//Player Attributes
const float player_speed_;
};
} //Namespace gdw
#endif
......@@ -18,15 +18,15 @@ namespace gdw{
~collision_component();
gdw::collision_shape* collision_shape() {return collision_shape_.get();}
void set_trigger(std::function<void()> trigger) {trigger_ = trigger;}
void call_trigger() {trigger_();}
void set_trigger(std::function<void(unsigned long long, unsigned long long)> trigger) {trigger_ = trigger;}
void call_trigger(unsigned long long self_id, unsigned long long coll_id) {trigger_(self_id, coll_id);}
static unsigned long long type_id() {
return gdw::type_id<gdw::collision_component>();
}
private:
std::unique_ptr<gdw::collision_shape> collision_shape_;
std::function<void()> trigger_;
std::function<void(unsigned long long, unsigned long long)> trigger_;
};
}
......
......@@ -6,9 +6,9 @@
#include <ecs/component.hpp>
#include <util/id.hpp>
#include <ecs/entity.hpp>
namespace gdw {
class entity;
class engine;
}
......
......@@ -16,6 +16,8 @@ namespace gdw {
class config_manager : public cached_resource_manager<config, config_manager> {
private:
engine& engine_;
std::vector<std::string> explode(const std::string& str, char delimiter);
std::string merge(asset_ptr &asset1, asset_ptr &asset2);
friend class cached_resource_manager<config, config_manager>;
......
recastnavigation @ 1dd5cf18
Subproject commit 1dd5cf1883d61e723fef3d4957cf758c50e7a52b
......@@ -15,6 +15,10 @@ namespace gdw {
void audio_collection::load_sound_collection() {
//insert new sound here
sound_collection_.insert(
std::pair<const std::string, sound_ptr>
("backgroundNoise", sound_manager_.load("sound/background_noise.ogg"))
);
}
music_ptr audio_collection::music(const std::string& name) const {
......
......@@ -20,18 +20,23 @@
#include <util/make_unique.hpp>
#include <game_state_machine/game_state_machine.h>
#include <physics/physics_system.h>
#include <gameplay/game_play_system.h>
namespace gdw {
engine::engine()
: quit_(false), config_manager_(*this), entity_manager_(*this) {
log("game.log");
this->config = this->config_manager().load("config/settings");
if (!this->config) {
throw std::runtime_error{"could not load config from file config/settings.user or config/settings.main"};
}
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
auto sdl_error = std::string(SDL_GetError());
SDL_ClearError();
throw std::runtime_error("could not initialize SDL" + sdl_error);
}
game_play_system_ = make_unique<gdw::game_play_system>(*this);
physics_system_ = make_unique<gdw::physics_system>(*this);
audio_ = make_unique<gdw::audio>(*this);
graphics_system_ = make_unique<gdw::graphics_system>(*this);
......
......@@ -9,16 +9,12 @@
namespace gdw {
window::window(engine& engine)
: engine_(engine), impl_(nullptr, +[](SDL_Window*) {}) {
auto config = engine_.config_manager().load("config/settings");
if (!config) {
throw std::runtime_error{"could not load config from file config/settings.user or config/settings.main"};
}
title_ = config->get<std::string>("title", "engine");
width_ = config->get<unsigned long long>("width", 800);
height_ = config->get<unsigned long long>("height", 600);
fullscreen_ = config->get<bool>("fullscreen", false);
borderless_ = config->get<bool>("borderless", false);
title_ = this->engine_.getConfig().get<std::string>("title", "engine");
width_ = this->engine_.getConfig().get<unsigned long long>("width", 800);
height_ = this->engine_.getConfig().get<unsigned long long>("height", 600);
fullscreen_ = this->engine_.getConfig().get<bool>("fullscreen", false);
borderless_ = this->engine_.getConfig().get<bool>("borderless", false);
auto window_mask = SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI;
if (fullscreen_) {
......
......@@ -2,7 +2,7 @@
namespace gdw {
game_state::game_state(engine &engine):engine_(engine) {
game_state::game_state(engine &engine):engine_(engine), channel(0) {
}
......
......@@ -5,6 +5,7 @@
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
#include <ecs/entity.hpp>
#include <input/input.hpp>
#include <game_state_machine/game_state_machine.h>
#include <game_state_machine/play_state.h>
......@@ -20,6 +21,8 @@ void menu_state::on_enter() {
}
void menu_state::update(float dt) {
if (this->engine_.input().isKeyPressed(SDLK_ESCAPE))
this->engine_.game_state_machine().change_state<play_state>();
}
void menu_state::on_exit() {
......
#include <audio/sound_manager.hpp>
#include <audio/audio.hpp>
#include <game_state_machine/play_state.h>
#include <util/id.hpp>
#include <core/engine.hpp>
......@@ -20,7 +22,13 @@
#include <iostream>
#include <util/make_unique.hpp>
#include <util/logger.hpp>
#include <util/config.hpp>
#include <input/input.hpp>
#include <time.h>
#include <gameplay/level_manager.h>
#include <glm/gtx/intersect.hpp>
#include <gameplay/game_input_manager.h>
#include <gameplay/game_play_system.h>
namespace gdw {
......@@ -31,63 +39,20 @@ play_state::play_state(engine &engine):game_state(engine) {
play_state::~play_state() {}
void play_state::on_enter() {
auto& entity_manager = engine_.entity_manager();
auto& rendering_system = engine_.rendering_system();
auto& camera = entity_manager.emplace_back(glm::vec3(0.f, 100.f, 0.f), glm::angleAxis(glm::radians(-90.f), glm::vec3(1.f, 0.f, 0.f)));
camera.emplace_back<camera_component>();
rendering_system.active_camera(camera.id());
auto& light = entity_manager.emplace_back(glm::vec3(5.f), glm::angleAxis(0.f, glm::vec3(0.f)));
light.emplace_back<light_component>(glm::vec3(1.f), 10.f);
auto& sun = entity_manager.emplace_back(glm::vec3(1.f, 0.3f, 1.f), glm::angleAxis(0.f, glm::vec3(0.f)));
sun.emplace_back<directional_light_component>(glm::vec3(1.f), 1.f);
sun.emplace_back<shadow_component>(200.f);
auto& plane = entity_manager.emplace_back(glm::vec3(0.f), glm::angleAxis(0.f, glm::vec3(0.f)), glm::vec3(100.f));
plane.emplace_back<staticmesh_component>("mesh/plane.msh");
for (auto x = -100.f; x <= 100.f; x += 3.4f) {
for (auto z = -10.f; z <= 10.f; z += 3.4f) {
auto& cube = entity_manager.emplace_back(glm::vec3(x, 1.2f, z), glm::angleAxis(glm::radians(0.f), glm::vec3(0.f, 1.f, 0.f)));
cube.emplace_back<staticmesh_component>("mesh/cube.msh");
}
}
wcube_ = &engine_.entity_manager().emplace_back(glm::vec3(0.f, 1.2f, 0.f), glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f)));
//wcube_->emplace_back<instanced_staticmesh_component>("mesh/pirate_ship.msh");
wcube_move_ = &wcube_->emplace_back<movement_component>();
// wcube2_ = &engine_.entity_manager().emplace_back(glm::vec3(0.f), glm::angleAxis(0.f, glm::vec3(0.f)));
// wcube2_->emplace_back<staticmesh_component>("mesh/cube.msh");
// auto &wcube_col2_ = wcube2_->emplace_back<collision_component>(new sphere(glm::vec3(0.f), 1.2f));
// //wcube_col2_.set_trigger([](){std::cout << "trigger 2" << std::endl;});
// wcube2_move_ = &wcube2_->emplace_back<movement_component>();
// wcube_move_->set_damping(0.001f);
// wcube_move_->set_mass(0.01f);
this->channel = this->engine_.audio().queue_sound("backgroundNoise", -1);
this->engine_.audio().sound_volume(5, this->channel);
engine_.game_play_system().level_manager().build_stage();
}
void play_state::update(float dt) {
/*static float t = 0.f;
static float neg = 1.f;
t += dt * neg;
if(t > 2.f || t < -2.f) {
neg *= -1.f;
}
wcube_move_->add_force(glm::vec3((2.f*neg),-(1.f*neg),0));
// wcube2_move_->add_force(glm::vec3(-(2.f*neg),(1.f*neg),0));
engine_.game_play_system().update(dt);
wcube_move_->set_angular_speed(3.f,5.f,1.f);
//wcube2_move_->set_angular_speed(-3.f,-5.f,-1.f);*/
if (this->engine_.input().isKeyPressed(SDLK_ESCAPE))
this->engine_.game_state_machine().change_state<menu_state>();
}
void play_state::on_exit() {
this->engine_.audio().stop_sound(this->channel);
}
} //namespace gdw
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment