Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn

This commit is contained in:
Tobias Dahl
2014-03-14 00:59:30 +01:00
19 changed files with 54 additions and 33 deletions
+1 -8
View File
@@ -1,13 +1,7 @@
#ifndef Camera_h__ #ifndef Camera_h__
#define Camera_h__ #define Camera_h__
#define GLM_FORCE_RADIANS #include "GLM.h"
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/rotate_vector.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
class Camera class Camera
{ {
@@ -56,7 +50,6 @@ private:
float m_NearClip; float m_NearClip;
float m_FarClip; float m_FarClip;
glm::vec3 m_Position; glm::vec3 m_Position;
glm::quat m_Orientation; glm::quat m_Orientation;
//float m_Pitch; //float m_Pitch;
+2
View File
@@ -1,6 +1,8 @@
#ifndef Component_h__ #ifndef Component_h__
#define Component_h__ #define Component_h__
#include "GLM.h"
#include "Factory.h" #include "Factory.h"
#include "Entity.h" #include "Entity.h"
-1
View File
@@ -2,7 +2,6 @@
#define Components_Bounds_h__ #define Components_Bounds_h__
#include "Component.h" #include "Component.h"
#include <glm/common.hpp>
namespace Components namespace Components
{ {
+2
View File
@@ -8,6 +8,8 @@ namespace Components
struct Camera : Component struct Camera : Component
{ {
Camera() : FOV(glm::radians(45.f)), NearClip(0.1f), FarClip(100.f) { }
float FOV; float FOV;
float NearClip; float NearClip;
float FarClip; float FarClip;
-1
View File
@@ -2,7 +2,6 @@
#define Components_Transform_h__ #define Components_Transform_h__
#include "Component.h" #include "Component.h"
#include <glm/gtc/quaternion.hpp>
namespace Components namespace Components
{ {
+1
View File
@@ -144,6 +144,7 @@
<ClInclude Include="Frame.h" /> <ClInclude Include="Frame.h" />
<ClInclude Include="GameFrame.h" /> <ClInclude Include="GameFrame.h" />
<ClInclude Include="GameWorld.h" /> <ClInclude Include="GameWorld.h" />
<ClInclude Include="GLM.h" />
<ClInclude Include="GUIManager.h" /> <ClInclude Include="GUIManager.h" />
<ClInclude Include="logging.h" /> <ClInclude Include="logging.h" />
<ClInclude Include="glerror.h" /> <ClInclude Include="glerror.h" />
@@ -154,6 +154,7 @@
<ClInclude Include="Systems\TransformSystem.h"> <ClInclude Include="Systems\TransformSystem.h">
<Filter>Systems</Filter> <Filter>Systems</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="GLM.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Shaders\Fragment.glsl"> <None Include="Shaders\Fragment.glsl">
+9
View File
@@ -0,0 +1,9 @@
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/common.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/rotate_vector.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtc/type_ptr.hpp>
+1 -1
View File
@@ -65,7 +65,7 @@ void GameWorld::Initialize()
AddComponent<Components::Input>(entcamera, "Input"); AddComponent<Components::Input>(entcamera, "Input");
transform->Position = glm::vec3(0.f, 10.f, 14.f); transform->Position = glm::vec3(0.f, 10.f, 14.f);
camera = AddComponent<Components::Camera>(entcamera, "Camera"); camera = AddComponent<Components::Camera>(entcamera, "Camera");
camera->FOV = 45.f; camera->FOV = glm::radians(45.f);
camera->FarClip = 1000.f; camera->FarClip = 1000.f;
camera->NearClip = 0.01f; camera->NearClip = 0.01f;
transform->Orientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0)); transform->Orientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0));
+1 -4
View File
@@ -9,10 +9,7 @@
#include <memory> #include <memory>
#include "OpenGL.h" #include "OpenGL.h"
#include <glm/glm.hpp> #include "GLM.h"
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <cstdlib> #include <cstdlib>
#include <stack> #include <stack>
+1 -1
View File
@@ -9,4 +9,4 @@ Ks 0.500000 0.500000 0.500000
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2
map_Kd ObstacleTexture.png map_Kd planetexture.png
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

-1
View File
@@ -2,4 +2,3 @@
#define GLFW_INCLUDE_GLU #define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <glext.h> #include <glext.h>
#define GLM_FORCE_RADIANS
+1 -6
View File
@@ -8,12 +8,7 @@
#include <vector> #include <vector>
#include "OpenGL.h" #include "OpenGL.h"
#include <glm/glm.hpp> #include "GLM.h"
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include "glerror.h" #include "glerror.h"
#include "Camera.h" #include "Camera.h"
@@ -8,6 +8,7 @@ Systems::LevelGenerationSystem::LevelGenerationSystem( World* world )
velocity = 0; velocity = 0;
startx = 0; startx = 0;
startyz = glm::vec2(0, -1000); startyz = glm::vec2(0, -1000);
spawnFrequency = 0.1f;
} }
void Systems::LevelGenerationSystem::SpawnObstacle() void Systems::LevelGenerationSystem::SpawnObstacle()
@@ -55,7 +56,7 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
else if(typeRandom >= 5 && typeRandom < 8) else if(typeRandom >= 5 && typeRandom < 8)
{ {
m_World->SetProperty(ent, "Name", std::string("Obstacle")); 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); transform->Scale = glm::vec3(scale);
bounds->VolumeVector = glm::vec3(1, 1, 1); bounds->VolumeVector = glm::vec3(1, 1, 1);
bounds->Origin = glm::vec3(0,1,0); bounds->Origin = glm::vec3(0,1,0);
@@ -85,8 +86,9 @@ void Systems::LevelGenerationSystem::Update( double dt )
{ {
elapsedtime += dt; elapsedtime += dt;
spawnFrequency = velocity/1000;
if(elapsedtime > 0.1){ if(elapsedtime > spawnFrequency){
SpawnObstacle(); SpawnObstacle();
elapsedtime = 0; elapsedtime = 0;
} }
@@ -33,6 +33,7 @@ namespace Systems
float startx; float startx;
double elapsedtime; double elapsedtime;
float velocity; float velocity;
float spawnFrequency;
}; };
} }
+24 -5
View File
@@ -12,6 +12,7 @@ Systems::PlayerSystem::PlayerSystem( World* world ) : System(world)
freecamEnabled = false; freecamEnabled = false;
m_poweruptimeleft = 0; m_poweruptimeleft = 0;
m_basespeed = 100.f; m_basespeed = 100.f;
m_maxspeed = 100.f;
} }
void Systems::PlayerSystem::Update(double dt) void Systems::PlayerSystem::Update(double dt)
@@ -162,6 +163,10 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
//powerup //powerup
auto cameraEntity = m_World->GetProperty<EntityID>(entity, "Camera");
auto cameracamera = m_World->GetComponent<Components::Camera>(cameraEntity, "Camera");
cameracamera->FOV = glm::radians(20.f + transform->Velocity.z/3 );
auto collisionComponent = m_World->GetComponent<Components::Collision>(entity, "Collision"); auto collisionComponent = m_World->GetComponent<Components::Collision>(entity, "Collision");
for(auto ent : collisionComponent->CollidingEntities) for(auto ent : collisionComponent->CollidingEntities)
{ {
@@ -169,27 +174,41 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
if(name == "PowerUp") if(name == "PowerUp")
{ {
auto powerupComp = m_World->GetComponent<Components::PowerUp>(ent, "PowerUp"); auto powerupComp = m_World->GetComponent<Components::PowerUp>(ent, "PowerUp");
transform->Velocity.z = powerupComp->Speed; m_maxspeed = powerupComp->Speed;
m_poweruptimeleft = 3.f; m_poweruptimeleft = 5.f;
m_World->RemoveEntity(ent); m_World->RemoveEntity(ent);
} }
} }
if(m_poweruptimeleft <= 0) 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 // Update camera
if(! freecamEnabled) if(! freecamEnabled)
{ {
auto cameraEntity = m_World->GetProperty<EntityID>(entity, "Camera");
auto cameraTransform = m_World->GetComponent<Components::Transform>(cameraEntity, "Transform"); auto cameraTransform = m_World->GetComponent<Components::Transform>(cameraEntity, "Transform");
if (cameraTransform) { if (cameraTransform) {
cameraTransform->Position = transform->Position + m_CameraOffset; cameraTransform->Position = transform->Position + m_CameraOffset;
cameraTransform->Orientation = m_CameraOrientation; cameraTransform->Orientation = m_CameraOrientation;
} }
} }
} }
} }
+3
View File
@@ -34,7 +34,10 @@ namespace Systems
glm::quat m_CameraOrientation; glm::quat m_CameraOrientation;
bool freecamEnabled; bool freecamEnabled;
float m_basespeed; float m_basespeed;
float m_maxspeed;
float m_poweruptimeleft; float m_poweruptimeleft;
}; };
-1
View File
@@ -7,7 +7,6 @@
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h> #include <AL/alc.h>
#include <vector> #include <vector>
#include <glm/gtx/quaternion.hpp>
namespace Systems namespace Systems
{ {