diff --git a/Escape-the-Dawn/Camera.h b/Escape-the-Dawn/Camera.h index bc2cb83..973ff5d 100644 --- a/Escape-the-Dawn/Camera.h +++ b/Escape-the-Dawn/Camera.h @@ -1,13 +1,7 @@ #ifndef Camera_h__ #define Camera_h__ -#define GLM_FORCE_RADIANS -#include -#include -#include -#include -#include -#include +#include "GLM.h" class Camera { @@ -55,7 +49,6 @@ private: float m_AspectRatio; float m_NearClip; float m_FarClip; - glm::vec3 m_Position; glm::quat m_Orientation; diff --git a/Escape-the-Dawn/Component.h b/Escape-the-Dawn/Component.h index 21d59f6..adaa4f7 100644 --- a/Escape-the-Dawn/Component.h +++ b/Escape-the-Dawn/Component.h @@ -1,6 +1,8 @@ #ifndef Component_h__ #define Component_h__ +#include "GLM.h" + #include "Factory.h" #include "Entity.h" diff --git a/Escape-the-Dawn/Components/Bounds.h b/Escape-the-Dawn/Components/Bounds.h index 3845485..f05c6d8 100644 --- a/Escape-the-Dawn/Components/Bounds.h +++ b/Escape-the-Dawn/Components/Bounds.h @@ -2,7 +2,6 @@ #define Components_Bounds_h__ #include "Component.h" -#include namespace Components { diff --git a/Escape-the-Dawn/Components/Camera.h b/Escape-the-Dawn/Components/Camera.h index 62d6905..2cd379d 100644 --- a/Escape-the-Dawn/Components/Camera.h +++ b/Escape-the-Dawn/Components/Camera.h @@ -8,6 +8,8 @@ namespace Components struct Camera : Component { + Camera() : FOV(glm::radians(45.f)), NearClip(0.1f), FarClip(100.f) { } + float FOV; float NearClip; float FarClip; diff --git a/Escape-the-Dawn/Components/Transform.h b/Escape-the-Dawn/Components/Transform.h index 5d20a67..8d0073f 100644 --- a/Escape-the-Dawn/Components/Transform.h +++ b/Escape-the-Dawn/Components/Transform.h @@ -2,7 +2,6 @@ #define Components_Transform_h__ #include "Component.h" -#include namespace Components { diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj b/Escape-the-Dawn/Escape-the-Dawn.vcxproj index d8c44c3..0b8fcfa 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj @@ -144,6 +144,7 @@ + diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters b/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters index 06f96a7..e19e833 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters @@ -154,6 +154,7 @@ Systems + diff --git a/Escape-the-Dawn/GLM.h b/Escape-the-Dawn/GLM.h new file mode 100644 index 0000000..db5bcc1 --- /dev/null +++ b/Escape-the-Dawn/GLM.h @@ -0,0 +1,9 @@ +#define GLM_FORCE_RADIANS +#include +#include +#include +#include +#include +#include +#include +#include \ No newline at end of file diff --git a/Escape-the-Dawn/GameWorld.cpp b/Escape-the-Dawn/GameWorld.cpp index 10657cd..7eb218e 100644 --- a/Escape-the-Dawn/GameWorld.cpp +++ b/Escape-the-Dawn/GameWorld.cpp @@ -65,7 +65,7 @@ void GameWorld::Initialize() AddComponent(entcamera, "Input"); transform->Position = glm::vec3(0.f, 10.f, 14.f); camera = AddComponent(entcamera, "Camera"); - camera->FOV = 45.f; + camera->FOV = glm::radians(45.f); camera->FarClip = 1000.f; camera->NearClip = 0.01f; transform->Orientation = glm::angleAxis(glm::radians(15.0f),glm::vec3(1,0,0)); diff --git a/Escape-the-Dawn/Model.h b/Escape-the-Dawn/Model.h index 716d1c2..2888f95 100644 --- a/Escape-the-Dawn/Model.h +++ b/Escape-the-Dawn/Model.h @@ -9,10 +9,7 @@ #include #include "OpenGL.h" -#include -#include -#include -#include +#include "GLM.h" #include #include diff --git a/Escape-the-Dawn/Models/plane.mtl b/Escape-the-Dawn/Models/plane.mtl index 2961836..28df6eb 100644 --- a/Escape-the-Dawn/Models/plane.mtl +++ b/Escape-the-Dawn/Models/plane.mtl @@ -9,4 +9,4 @@ Ks 0.500000 0.500000 0.500000 Ni 1.000000 d 1.000000 illum 2 -map_Kd ObstacleTexture.png +map_Kd planetexture.png diff --git a/Escape-the-Dawn/Models/planetexture.png b/Escape-the-Dawn/Models/planetexture.png new file mode 100644 index 0000000..6766b13 Binary files /dev/null and b/Escape-the-Dawn/Models/planetexture.png differ diff --git a/Escape-the-Dawn/OpenGL.h b/Escape-the-Dawn/OpenGL.h index dec332d..2e34a34 100644 --- a/Escape-the-Dawn/OpenGL.h +++ b/Escape-the-Dawn/OpenGL.h @@ -1,5 +1,4 @@ #include #define GLFW_INCLUDE_GLU #include -#include -#define GLM_FORCE_RADIANS \ No newline at end of file +#include \ No newline at end of file diff --git a/Escape-the-Dawn/Renderer.h b/Escape-the-Dawn/Renderer.h index 5c35b4f..777643c 100644 --- a/Escape-the-Dawn/Renderer.h +++ b/Escape-the-Dawn/Renderer.h @@ -8,12 +8,7 @@ #include #include "OpenGL.h" -#include -#include -#include -#include -#include -#include +#include "GLM.h" #include "glerror.h" #include "Camera.h" diff --git a/Escape-the-Dawn/Systems/LevelGenerationSystem.cpp b/Escape-the-Dawn/Systems/LevelGenerationSystem.cpp index 8959784..0804afc 100644 --- a/Escape-the-Dawn/Systems/LevelGenerationSystem.cpp +++ b/Escape-the-Dawn/Systems/LevelGenerationSystem.cpp @@ -8,6 +8,7 @@ Systems::LevelGenerationSystem::LevelGenerationSystem( World* world ) velocity = 0; startx = 0; startyz = glm::vec2(0, -1000); + spawnFrequency = 0.1f; } void Systems::LevelGenerationSystem::SpawnObstacle() @@ -55,7 +56,7 @@ void Systems::LevelGenerationSystem::SpawnObstacle() else if(typeRandom >= 5 && typeRandom < 8) { m_World->SetProperty(ent, "Name", std::string("Obstacle")); - float scale = (float)(rand() % 1000) / 100; + float scale = 1.f + (float)(rand() % 1000) / 100; transform->Scale = glm::vec3(scale); bounds->VolumeVector = glm::vec3(1, 1, 1); bounds->Origin = glm::vec3(0,1,0); @@ -85,8 +86,9 @@ void Systems::LevelGenerationSystem::Update( double dt ) { elapsedtime += dt; + spawnFrequency = velocity/1000; - if(elapsedtime > 0.1){ + if(elapsedtime > spawnFrequency){ SpawnObstacle(); elapsedtime = 0; } diff --git a/Escape-the-Dawn/Systems/LevelGenerationSystem.h b/Escape-the-Dawn/Systems/LevelGenerationSystem.h index ab02fe3..7d0339d 100644 --- a/Escape-the-Dawn/Systems/LevelGenerationSystem.h +++ b/Escape-the-Dawn/Systems/LevelGenerationSystem.h @@ -33,6 +33,7 @@ namespace Systems float startx; double elapsedtime; float velocity; + float spawnFrequency; }; } diff --git a/Escape-the-Dawn/Systems/PlayerSystem.cpp b/Escape-the-Dawn/Systems/PlayerSystem.cpp index 8080fa5..177b6bf 100644 --- a/Escape-the-Dawn/Systems/PlayerSystem.cpp +++ b/Escape-the-Dawn/Systems/PlayerSystem.cpp @@ -12,6 +12,7 @@ Systems::PlayerSystem::PlayerSystem( World* world ) : System(world) freecamEnabled = false; m_poweruptimeleft = 0; m_basespeed = 100.f; + m_maxspeed = 100.f; } void Systems::PlayerSystem::Update(double dt) @@ -162,6 +163,10 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa //powerup + auto cameraEntity = m_World->GetProperty(entity, "Camera"); + auto cameracamera = m_World->GetComponent(cameraEntity, "Camera"); + cameracamera->FOV = glm::radians(20.f + transform->Velocity.z/3 ); + auto collisionComponent = m_World->GetComponent(entity, "Collision"); for(auto ent : collisionComponent->CollidingEntities) { @@ -169,27 +174,41 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa if(name == "PowerUp") { auto powerupComp = m_World->GetComponent(ent, "PowerUp"); - transform->Velocity.z = powerupComp->Speed; - m_poweruptimeleft = 3.f; - m_World->RemoveEntity(ent); + m_maxspeed = powerupComp->Speed; + m_poweruptimeleft = 5.f; + m_World->RemoveEntity(ent); + } } if(m_poweruptimeleft <= 0) { - transform->Velocity.z = m_basespeed; + m_maxspeed = m_basespeed; } - //fixa FOV + if(transform->Velocity.z < m_maxspeed) + { + transform->Velocity.z += 100.f*dt; + if(transform->Velocity.z >= m_maxspeed) + transform->Velocity.z = m_maxspeed; + } + else if(transform->Velocity.z > m_maxspeed) + { + transform->Velocity.z -= 50.f*dt; + if(transform->Velocity.z <= m_maxspeed) + transform->Velocity.z = m_maxspeed; + } + // Update camera if(! freecamEnabled) { - auto cameraEntity = m_World->GetProperty(entity, "Camera"); auto cameraTransform = m_World->GetComponent(cameraEntity, "Transform"); if (cameraTransform) { cameraTransform->Position = transform->Position + m_CameraOffset; cameraTransform->Orientation = m_CameraOrientation; } + + } } } diff --git a/Escape-the-Dawn/Systems/PlayerSystem.h b/Escape-the-Dawn/Systems/PlayerSystem.h index 9da1204..993ee20 100644 --- a/Escape-the-Dawn/Systems/PlayerSystem.h +++ b/Escape-the-Dawn/Systems/PlayerSystem.h @@ -34,7 +34,10 @@ namespace Systems glm::quat m_CameraOrientation; bool freecamEnabled; + float m_basespeed; + float m_maxspeed; + float m_poweruptimeleft; }; diff --git a/Escape-the-Dawn/Systems/SoundSystem.h b/Escape-the-Dawn/Systems/SoundSystem.h index f8b97eb..303b5c5 100644 --- a/Escape-the-Dawn/Systems/SoundSystem.h +++ b/Escape-the-Dawn/Systems/SoundSystem.h @@ -7,7 +7,6 @@ #include #include #include -#include namespace Systems {