Merge remote-tracking branch 'origin/master' into Physics

Conflicts:
	include/Core/Engine.h
	src/game/Game/PadSystem.cpp
	src/game/Physics/PhysicsSystem.cpp
This commit is contained in:
viktorljung
2015-09-17 17:11:37 +02:00
48 changed files with 19163 additions and 223 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ namespace Components
struct Ball : Component
{
int Number = 0;
};
}
+1
View File
@@ -17,6 +17,7 @@ struct Brick : Component
{
int Points = 10;
int Hits = 1;
int Score = 50;
};
}
+26
View File
@@ -0,0 +1,26 @@
//
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_CLIFE_H
#define DAYDREAM_CLIFE_H
#include "Core/Component.h"
namespace dd
{
namespace Components
{
struct Life : Component {
int Number = 0;
};
}
}
#endif //DAYDREAM_CLIFE_H
+4
View File
@@ -19,6 +19,10 @@ struct Pad : Component
{
int Lives;
int Points;
float SlowdownModifier = 5.f;
float AccelerationSpeed = 80.f;
float MaxSpeed = 40.f;
};
}
+27
View File
@@ -0,0 +1,27 @@
//
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_ELIFELOST_H
#define DAYDREAM_ELIFELOST_H
#include "Core/EventBroker.h"
#include "Core/Entity.h"
namespace dd
{
namespace Events
{
struct LifeLost : Event
{
EntityID Entity;
};
}
}
#endif //DAYDREAM_ELIFELOST_H
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_ERESETBALL_H
#define DAYDREAM_ERESETBALL_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct ResetBall : Event
{
};
}
}
#endif //DAYDREAM_ERESETBALL_H
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_ESCOREEVENT_H
#define DAYDREAM_ESCOREEVENT_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct ScoreEvent : Event
{
int Score = 0;
};
}
}
#endif //DAYDREAM_ESCOREEVENT_H
Regular → Executable
+45 -10
View File
@@ -8,14 +8,21 @@
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Rendering/CSprite.h"
#include "Rendering/CModel.h"
#include "Game/CBrick.h"
#include "Physics/EContact.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
#include "Game/CBall.h"
#include "Game/CLife.h"
#include "Game/EStageCleared.h"
#include "Game/ELifeLost.h"
#include "Game/EResetBall.h"
#include "Game/EScoreEvent.h"
#include "Physics/CBoxShape.h"
#include "Physics/CPhysics.h"
#include "Physics/CCircleShape.h"
#include "Physics/ESetImpulse.h"
#include "Physics/EContact.h"
#include <fstream>
#include <iostream>
#include <intrin.h>
@@ -47,6 +54,7 @@ public:
void Initialize() override;
void CreateBasicLevel(int, int, glm::vec2, int);
void CreateLife(int);
void SaveLevel(int, int, glm::vec2, int); // Shouldn't be here, but I'm experimenting.
void LoadLevel(char[20]);
void CreateBrick(int, int, glm::vec2, int, int);
@@ -56,20 +64,47 @@ public:
void EndLevel();
void Update(double dt);
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
bool Initialized() const { return m_Initialized; }
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
int& Lives() { return m_Lives; }
void SetLives(const int& lives) { m_Lives = lives; }
int& PastLives() { return m_PastLives; }
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
int& Score() { return m_Score; }
void SetScore(const int& score) { m_Score = score; }
int& NumberOfBricks() { return m_NumberOfBricks; }
void SetNumberOfBricks(const int& numberOfBricks) { m_NumberOfBricks = numberOfBricks; }
int& Rows() { return m_Rows; }
void SetRows(const int& rows) { m_Rows = rows; }
int& Lines() { return m_Lines; }
void SetLines(const int& lines) { m_Lines = lines; }
int& SpaceToEdge() { return m_SpaceToEdge; }
void SetSpaceToEdge(const int& spaceToEdge) { m_SpaceToEdge = spaceToEdge; }
glm::vec2& SpaceBetweenBricks() { return m_SpaceBetweenBricks; }
void SetSpaceBetweenBricks(const glm::vec2& spaceBetweenBricks) { m_SpaceBetweenBricks = spaceBetweenBricks; }
private:
bool m_Initialized = false;
int m_Lives = 3;
int m_PastLives = 3;
int m_Score = 0;
int m_NumberOfBricks;
int m_Rows = 7;
int m_Lines = 8;
int m_SpaceToEdge = 0;
glm::vec2 m_SpaceBetweenBricks = glm::vec2(2, 0.5);
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<LevelSystem, dd::Events::LifeLost> m_ELifeLost;
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
bool OnContact(const dd::Events::Contact &event);
bool m_Initialized = false;
int numberOfBricks;
int tRows = 7;
int tLines = 8;
glm::vec2 tSpaceBetweenBricks = glm::vec2(2, 0.5);
int tSpaceToEdge = 0;
bool LifeLost(const dd::Events::LifeLost &event);
bool ScoreEvent(const dd::Events::ScoreEvent &event);
};
}
Regular → Executable
+35 -17
View File
@@ -7,19 +7,22 @@
#include "Core/InputController.h"
#include "Core/System.h"
#include "Core/Component.h"
#include "Core/CTransform.h"
#include "Core/EventBroker.h"
#include "Core/EKeyDown.h"
#include "Core/EKeyUp.h"
#include "Input/EBindKey.h"
#include "Physics/EContact.h"
#include "Core/CTransform.h"
#include "Physics/CBoxShape.h"
#include "Physics/CPhysics.h"
#include "Rendering/CSprite.h"
#include "Game/CBall.h"
#include "Core/Component.h"
#include "Physics/ESetImpulse.h"
#include "Physics/CCircleShape.h"
#include "Physics/ESetImpulse.h"
#include "Rendering/CSprite.h"
#include "Rendering/CModel.h"
#include "Game/CBall.h"
#include "Game/EResetBall.h"
#include "CPad.h"
namespace dd
@@ -32,34 +35,49 @@ class PadSystem : public System
{
public:
PadSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker)
{ }
: System(world, eventBroker) { }
void Initialize() override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
EntityID& Entity() { return m_Entity; }
void SetEntity(const EntityID& ent) { m_Entity = ent; }
glm::vec3 Acceleration() const { return m_Acceleration; }
void SetAcceleration(const glm::vec3& acceleration) { m_Acceleration = acceleration; }
bool Left() const { return m_Left; }
void SetLeft(const bool& left) { m_Left = left; }
bool Right() const { return m_Right; }
void SetRight(const bool& right) { m_Right = right; }
bool ReplaceBall() const { return m_ReplaceBall; }
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
Components::Transform* Transform() const { return m_Transform; }
void SetTransform(const Components::Transform* transform) { m_Transform = transform; }
Components::Pad* Pad() const { return m_Pad; }
void SetPad(const Components::Pad* pad) { m_Pad = pad; }
private:
EntityID m_Entity = 0;
glm::vec3 m_Acceleration = glm::vec3(0.f, 0.f, 0.f);
bool m_Left = false, m_Right = false, m_ReplaceBall = false;
Components::Transform* m_Transform;
Components::Pad* m_Pad;
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<PadSystem, dd::Events::ResetBall> m_EResetBall;
bool OnKeyDown(const dd::Events::KeyDown &event);
bool OnKeyUp(const dd::Events::KeyUp &event);
bool OnContact(const dd::Events::Contact &event);
bool ResetBall(const dd::Events::ResetBall &event);
class PadSteeringInputController;
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
EntityID ent = 0;
Components::Transform* transform;
glm::vec3 acceleration = glm::vec3(0.f, 0.f, 0.f);
bool left = false, right = false;
};
class PadSystem::PadSteeringInputController : InputController<PadSystem>