Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn
Conflicts: Escape-the-Dawn/Systems/PlayerSystem.cpp
This commit is contained in:
+76
-13
@@ -3,48 +3,71 @@
|
|||||||
GUI::Frame::Frame()
|
GUI::Frame::Frame()
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle();
|
rectangle = new Rectangle();
|
||||||
|
texture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GUI::Frame::GetWidth()
|
int GUI::Frame::GetWidth()
|
||||||
{
|
{
|
||||||
return rectangle;
|
return rectangle->Width();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GUI::Frame::GetHeight()
|
int GUI::Frame::GetHeight()
|
||||||
{
|
{
|
||||||
return rectangle.Height();
|
return rectangle->Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GUI::Frame::GetX()
|
int GUI::Frame::GetX()
|
||||||
{
|
{
|
||||||
return rectangle;
|
return rectangle->X();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GUI::Frame::GetY()
|
int GUI::Frame::GetY()
|
||||||
{
|
{
|
||||||
return rectangle.Y();
|
return rectangle->Y();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::Frame::SetWidth(int wid)
|
int GUI::Frame::GetRight()
|
||||||
{
|
{
|
||||||
rectangle.width(wid);
|
return rectangle->Right();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::Frame::SetHeight(int hei)
|
int GUI::Frame::GetLeft()
|
||||||
{
|
{
|
||||||
rectangle.height(hei);
|
return rectangle->Left();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::Frame::SetX(int xcord)
|
int GUI::Frame::GetBottom()
|
||||||
{
|
{
|
||||||
rectangle.X(xcord)
|
return rectangle->Bottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::Frame::SetY(int ycord)
|
int GUI::Frame::GetTop()
|
||||||
{
|
{
|
||||||
rectangle.Y(ycord)
|
return rectangle->Right();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::Frame::SetWidth(int _width)
|
||||||
|
{
|
||||||
|
rectangle->Width(_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::Frame::SetHeight(int _height)
|
||||||
|
{
|
||||||
|
rectangle->Height(_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::Frame::SetX(int _x)
|
||||||
|
{
|
||||||
|
rectangle->X(_x);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::Frame::SetY(int _y)
|
||||||
|
{
|
||||||
|
rectangle->Y(_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Rectangle GUI::Frame::AbsouluteRectangle()
|
Rectangle GUI::Frame::AbsouluteRectangle()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -85,8 +108,48 @@ void GUI::Frame::Update(double dt)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddChild(GUI::Frame childFrame)
|
||||||
|
{
|
||||||
|
childFrame.Parent = this;
|
||||||
|
if (!Children.Contains(childFrame))
|
||||||
|
Children.Add(childFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a child frame from the frame.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="childFrame">The child frame to remove.</param>
|
||||||
|
void RemoveChild(GUI::Frame childFrame)
|
||||||
|
{
|
||||||
|
if (Children.Contains(childFrame))
|
||||||
|
Children.Remove(childFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destroys the frame and all its children.
|
||||||
|
/// </summary>
|
||||||
|
void Destroy()
|
||||||
|
{
|
||||||
|
if (Parent != null)
|
||||||
|
Parent.RemoveChild(this);
|
||||||
|
|
||||||
|
Manager.Remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::Frame::SetTexture(std::string fileName)
|
||||||
|
{
|
||||||
|
//texture == någonTextureIDunno;
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::Frame::Draw()
|
void GUI::Frame::Draw()
|
||||||
{
|
{
|
||||||
|
if (Visible)
|
||||||
|
{
|
||||||
|
if (texture != nullptr)
|
||||||
|
{
|
||||||
|
//Drawshit
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
+14
-9
@@ -1,4 +1,4 @@
|
|||||||
/*#ifndef Frame_h__
|
#ifndef Frame_h__
|
||||||
#define Frame_h__
|
#define Frame_h__
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "GUIManager.h"
|
#include "GUIManager.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
//#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
namespace GUI
|
namespace GUI
|
||||||
{
|
{
|
||||||
@@ -22,14 +22,19 @@ public:
|
|||||||
int GetHeight();
|
int GetHeight();
|
||||||
int GetX();
|
int GetX();
|
||||||
int GetY();
|
int GetY();
|
||||||
void SetWidth(int wid);
|
int GetRight();
|
||||||
void SetHeight(int hei);
|
int GetLeft();
|
||||||
void SetX( int xcord);
|
int GetBottom();
|
||||||
void SetY(int ycord);
|
int GetTop();
|
||||||
|
void SetWidth(int _width);
|
||||||
|
void SetHeight(int _height);
|
||||||
|
void SetX( int _x);
|
||||||
|
void SetY(int _y);
|
||||||
|
void SetTexture(std::string fileName);
|
||||||
Rectangle *rectangle;
|
Rectangle *rectangle;
|
||||||
Rectangle AbsouluteRectangle();
|
Rectangle AbsouluteRectangle();
|
||||||
Texture texture;
|
Texture* texture;
|
||||||
Color color;
|
Color* color;
|
||||||
bool _Visible;
|
bool _Visible;
|
||||||
bool Visible();
|
bool Visible();
|
||||||
int layer;
|
int layer;
|
||||||
@@ -48,4 +53,4 @@ protected:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif*/
|
#endif
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
int GUI::GUIManager::Add(Frame frame)
|
int GUI::GUIManager::Add(Frame frame)
|
||||||
{
|
{
|
||||||
//Frame.Add(frame);
|
Frame.Add(frame);
|
||||||
//return CreateUID();
|
return CreateUID();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*#ifndef GUIManager_h__
|
#ifndef GUIManager_h__
|
||||||
#define GUIManager_h__
|
#define GUIManager_h__
|
||||||
|
|
||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
@@ -18,9 +18,8 @@ private:
|
|||||||
static int uidIndex;
|
static int uidIndex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif */
|
#endif
|
||||||
@@ -22,6 +22,14 @@ public:
|
|||||||
|
|
||||||
int Y() const { return y; }
|
int Y() const { return y; }
|
||||||
void Y(int val) { y = val; }
|
void Y(int val) { y = val; }
|
||||||
|
|
||||||
|
int Left() const { return x; }
|
||||||
|
|
||||||
|
int Right() const { return x+width; }
|
||||||
|
|
||||||
|
int Top() const { return y; }
|
||||||
|
|
||||||
|
int Bottom() const { return y+height; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Rectangle::Rectangle()
|
Rectangle::Rectangle()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ in VertexData {
|
|||||||
vec3 ShadowCoord;
|
vec3 ShadowCoord;
|
||||||
} Input;
|
} Input;
|
||||||
|
|
||||||
vec3 scene_ambient = vec3(0.3);
|
vec3 scene_ambient = vec3(0.98f, 0.95f, 0.8f);
|
||||||
|
|
||||||
out vec4 fragmentColor;
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ void main() {
|
|||||||
float bias = 0.0005;
|
float bias = 0.0005;
|
||||||
vec4 shadowMapValue = texture(shadowMap, Input.ShadowCoord.xy);
|
vec4 shadowMapValue = texture(shadowMap, Input.ShadowCoord.xy);
|
||||||
if (shadowMapValue.z < clamp(Input.ShadowCoord.z - bias, 0, 1)) {
|
if (shadowMapValue.z < clamp(Input.ShadowCoord.z - bias, 0, 1)) {
|
||||||
visibility = 0.5;
|
visibility = 0.3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Systems::PlayerSystem::PlayerSystem( World* world ) : System(world)
|
|||||||
m_CameraOffset = glm::vec3(0.f, 5.f, 14.f);
|
m_CameraOffset = glm::vec3(0.f, 5.f, 14.f);
|
||||||
m_CameraOrientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0));
|
m_CameraOrientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0));
|
||||||
|
|
||||||
m_freecamEnabled = false;
|
freecamEnabled = false;
|
||||||
m_poweruptimeleft = 0;
|
m_poweruptimeleft = 0;
|
||||||
m_basespeed = 100.f;
|
m_basespeed = 100.f;
|
||||||
}
|
}
|
||||||
@@ -28,15 +28,30 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
if (input == nullptr)
|
if (input == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto collision = m_World->GetComponent<Components::Collision>(entity, "Collision");
|
||||||
|
|
||||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||||
if (name == "Camera") {
|
if(collision != nullptr)
|
||||||
if(input->KeyState[GLFW_KEY_F4] && !input->LastKeyState[GLFW_KEY_F4]) {
|
{
|
||||||
if(m_freecamEnabled)
|
for(auto ent : collision->CollidingEntities)
|
||||||
m_freecamEnabled = false;
|
{
|
||||||
else
|
if(m_World->GetProperty<std::string>(ent, "Name") == "Obstacle")
|
||||||
m_freecamEnabled = true;
|
{
|
||||||
|
m_World->RemoveEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(m_freecamEnabled)
|
}
|
||||||
|
|
||||||
|
if (name == "Camera") {
|
||||||
|
|
||||||
|
if(input->KeyState[GLFW_KEY_F4] && !input->LastKeyState[GLFW_KEY_F4]) {
|
||||||
|
if(freecamEnabled)
|
||||||
|
freecamEnabled = false;
|
||||||
|
else
|
||||||
|
freecamEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(freecamEnabled)
|
||||||
{
|
{
|
||||||
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
||||||
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
||||||
@@ -128,6 +143,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
transform->Position -= Ship_Right * (float)dt * Euler.z;
|
||||||
if(Euler.z < 1.5f && Euler.z > -1.5f)
|
if(Euler.z < 1.5f && Euler.z > -1.5f)
|
||||||
transform->Orientation = glm::angleAxis<float>(0,glm::vec3(0,0,1));
|
transform->Orientation = glm::angleAxis<float>(0,glm::vec3(0,0,1));
|
||||||
else if(Euler.z < 0.f)
|
else if(Euler.z < 0.f)
|
||||||
@@ -166,7 +182,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
|
|
||||||
|
|
||||||
// Update camera
|
// Update camera
|
||||||
if(! m_freecamEnabled)
|
if(! freecamEnabled)
|
||||||
{
|
{
|
||||||
auto cameraEntity = m_World->GetProperty<EntityID>(entity, "Camera");
|
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");
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace Systems
|
|||||||
glm::vec3 m_CameraOffset;
|
glm::vec3 m_CameraOffset;
|
||||||
glm::quat m_CameraOrientation;
|
glm::quat m_CameraOrientation;
|
||||||
|
|
||||||
bool m_freecamEnabled;
|
bool freecamEnabled;
|
||||||
float m_basespeed;
|
float m_basespeed;
|
||||||
float m_poweruptimeleft;
|
float m_poweruptimeleft;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user