From 3378e75313d749d0590f86945f2901660ec69c99 Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Fri, 14 Mar 2014 00:00:36 +0100 Subject: [PATCH 1/3] Powerup FOV fixed --- Escape-the-Dawn/Models/plane.mtl | 2 +- Escape-the-Dawn/Models/planetexture.png | Bin 0 -> 6952 bytes .../Systems/LevelGenerationSystem.cpp | 2 +- Escape-the-Dawn/Systems/PlayerSystem.cpp | 13 ++++++++++--- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 Escape-the-Dawn/Models/planetexture.png 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 0000000000000000000000000000000000000000..6766b13687f00ca520be4c54e86d6a2b55ac33bc GIT binary patch literal 6952 zcmeAS@N?(olHy`uVBq!ia0y~yVA%k|985rw6lawgK#IM@)7O>#9y70)g`mkgGfSY5 zc!_I7NpOBzNqJ&XDucU^3(y#aveY64V?C3?)+G;tN;pai{M>;u#y~cMSA(WJkYY)9 z^mSxl*x1kgCy^D%XG`*ScVYMsf(!O8pUl7@)$Hlw7*a9k&2>dapb-ZQeu*CwV*aRm z@NGJf?=kB=$gnyICkBQF4QCDp27y!#p!gylMFs|kDT*u%3>`)-Kox;)0t^farv!kW zaFHBUJQ^CKX=5~}j1~o>1>= 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); diff --git a/Escape-the-Dawn/Systems/PlayerSystem.cpp b/Escape-the-Dawn/Systems/PlayerSystem.cpp index 8080fa5..070b355 100644 --- a/Escape-the-Dawn/Systems/PlayerSystem.cpp +++ b/Escape-the-Dawn/Systems/PlayerSystem.cpp @@ -162,6 +162,9 @@ 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"); + auto collisionComponent = m_World->GetComponent(entity, "Collision"); for(auto ent : collisionComponent->CollidingEntities) { @@ -171,25 +174,29 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa auto powerupComp = m_World->GetComponent(ent, "PowerUp"); transform->Velocity.z = powerupComp->Speed; m_poweruptimeleft = 3.f; - m_World->RemoveEntity(ent); + m_World->RemoveEntity(ent); + + + cameracamera->FOV = 55.f; } } if(m_poweruptimeleft <= 0) { transform->Velocity.z = m_basespeed; + cameracamera->FOV = 45.f; } - //fixa FOV // 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; } + + } } } From 23701c4ac20583fee2339b8ed1a731b6312669d7 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 14 Mar 2014 00:37:09 +0100 Subject: [PATCH 2/3] GLM... radians pls. --- Escape-the-Dawn/Camera.h | 9 +-------- Escape-the-Dawn/Component.h | 2 ++ Escape-the-Dawn/Components/Bounds.h | 1 - Escape-the-Dawn/Components/Transform.h | 1 - Escape-the-Dawn/Escape-the-Dawn.vcxproj | 1 + Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters | 1 + Escape-the-Dawn/GLM.h | 9 +++++++++ Escape-the-Dawn/Model.h | 5 +---- Escape-the-Dawn/OpenGL.h | 3 +-- Escape-the-Dawn/Renderer.h | 7 +------ Escape-the-Dawn/Systems/SoundSystem.h | 1 - 11 files changed, 17 insertions(+), 23 deletions(-) create mode 100644 Escape-the-Dawn/GLM.h 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/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/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/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/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 { From 4b9cb71cca13edd1cd0959f30f15e06fdd66892d Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Fri, 14 Mar 2014 00:57:52 +0100 Subject: [PATCH 3/3] Fixad FOV Levelgen Spawnfrequency --- Escape-the-Dawn/Components/Camera.h | 2 ++ Escape-the-Dawn/GameWorld.cpp | 2 +- .../Systems/LevelGenerationSystem.cpp | 4 +++- .../Systems/LevelGenerationSystem.h | 1 + Escape-the-Dawn/Systems/PlayerSystem.cpp | 24 ++++++++++++++----- Escape-the-Dawn/Systems/PlayerSystem.h | 3 +++ 6 files changed, 28 insertions(+), 8 deletions(-) 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/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/Systems/LevelGenerationSystem.cpp b/Escape-the-Dawn/Systems/LevelGenerationSystem.cpp index 31e31da..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() @@ -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 070b355..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) @@ -164,6 +165,7 @@ 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) @@ -172,19 +174,29 @@ 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_maxspeed = powerupComp->Speed; + m_poweruptimeleft = 5.f; m_World->RemoveEntity(ent); - - cameracamera->FOV = 55.f; } } if(m_poweruptimeleft <= 0) { - transform->Velocity.z = m_basespeed; - cameracamera->FOV = 45.f; + m_maxspeed = m_basespeed; } + 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 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; };