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__
#define Camera_h__
#define GLM_FORCE_RADIANS
#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>
#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;
+2
View File
@@ -1,6 +1,8 @@
#ifndef Component_h__
#define Component_h__
#include "GLM.h"
#include "Factory.h"
#include "Entity.h"
-1
View File
@@ -2,7 +2,6 @@
#define Components_Bounds_h__
#include "Component.h"
#include <glm/common.hpp>
namespace Components
{
+2
View File
@@ -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;
-1
View File
@@ -2,7 +2,6 @@
#define Components_Transform_h__
#include "Component.h"
#include <glm/gtc/quaternion.hpp>
namespace Components
{
+1
View File
@@ -144,6 +144,7 @@
<ClInclude Include="Frame.h" />
<ClInclude Include="GameFrame.h" />
<ClInclude Include="GameWorld.h" />
<ClInclude Include="GLM.h" />
<ClInclude Include="GUIManager.h" />
<ClInclude Include="logging.h" />
<ClInclude Include="glerror.h" />
@@ -154,6 +154,7 @@
<ClInclude Include="Systems\TransformSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="GLM.h" />
</ItemGroup>
<ItemGroup>
<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");
transform->Position = glm::vec3(0.f, 10.f, 14.f);
camera = AddComponent<Components::Camera>(entcamera, "Camera");
camera->FOV = 45.f;
camera->FOV = glm::radians(45.f);
camera->FarClip = 1000.f;
camera->NearClip = 0.01f;
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 "OpenGL.h"
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "GLM.h"
#include <cstdlib>
#include <stack>
+1 -1
View File
@@ -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
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

+1 -2
View File
@@ -1,5 +1,4 @@
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glext.h>
#define GLM_FORCE_RADIANS
#include <glext.h>
+1 -6
View File
@@ -8,12 +8,7 @@
#include <vector>
#include "OpenGL.h"
#include <glm/glm.hpp>
#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 "GLM.h"
#include "glerror.h"
#include "Camera.h"
@@ -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;
}
@@ -33,6 +33,7 @@ namespace Systems
float startx;
double elapsedtime;
float velocity;
float spawnFrequency;
};
}
+25 -6
View File
@@ -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<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");
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<Components::PowerUp>(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<EntityID>(entity, "Camera");
auto cameraTransform = m_World->GetComponent<Components::Transform>(cameraEntity, "Transform");
if (cameraTransform) {
cameraTransform->Position = transform->Position + m_CameraOffset;
cameraTransform->Orientation = m_CameraOrientation;
}
}
}
}
+3
View File
@@ -34,7 +34,10 @@ namespace Systems
glm::quat m_CameraOrientation;
bool freecamEnabled;
float m_basespeed;
float m_maxspeed;
float m_poweruptimeleft;
};
-1
View File
@@ -7,7 +7,6 @@
#include <AL/al.h>
#include <AL/alc.h>
#include <vector>
#include <glm/gtx/quaternion.hpp>
namespace Systems
{