Animations
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -22,6 +22,7 @@ struct Ball : Component
|
|||||||
bool Waiting = true;
|
bool Waiting = true;
|
||||||
bool InkBlaster = false;
|
bool InkBlaster = false;
|
||||||
bool Sticky = false;
|
bool Sticky = false;
|
||||||
|
bool Loaded = false;
|
||||||
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
||||||
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ private:
|
|||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
int m_LooseBricks = 0;
|
int m_LooseBricks = 0;
|
||||||
int m_CurrentCluster = 1;
|
int m_CurrentCluster = 1;
|
||||||
int m_CurrentLevel = 1;
|
int m_CurrentLevel = 4;
|
||||||
int m_MultiBalls = 0;
|
int m_MultiBalls = 0;
|
||||||
int m_PowerUps = 0;
|
int m_PowerUps = 0;
|
||||||
int m_Score = 0;
|
int m_Score = 0;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "Rendering/CAnimation.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
transform->Orientation = glm::quat();
|
transform->Orientation = glm::quat();
|
||||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||||
model->ModelFile = "Models/Sid/Sid.dae";
|
model->ModelFile = "Models/Sid/Sid_Flying.dae";
|
||||||
auto animation = m_World->AddComponent<Components::Animation>(ent);
|
auto animation = m_World->AddComponent<Components::Animation>(ent);
|
||||||
animation->Speed = 1.0;
|
animation->Speed = 1.0;
|
||||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||||
|
|||||||
@@ -112,14 +112,19 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entity);
|
auto ballTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
ballTransform->Position = Transform()->Position;
|
ballTransform->Position = Transform()->Position;
|
||||||
ballTransform->Position += ball->StickyPlacement;
|
ballTransform->Position += ball->StickyPlacement;
|
||||||
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
|
if (ball->Loaded) {
|
||||||
glm::vec2 up = glm::vec2(0.f, 1.f);
|
ballTransform->Orientation = glm::quat();
|
||||||
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
} else {
|
||||||
ballTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
|
||||||
if (ball->Sticky) {
|
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||||
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
|
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
||||||
m_StickTransform->Position = ballTransform->Position;
|
ballTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
||||||
|
if (ball->Sticky) {
|
||||||
|
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
|
||||||
|
m_StickTransform->Position = ballTransform->Position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!m_StickyAim->Aiming) {
|
if (!m_StickyAim->Aiming) {
|
||||||
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
|
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
|
||||||
|
|||||||
@@ -109,8 +109,17 @@ bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &e
|
|||||||
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
||||||
{
|
{
|
||||||
if (m_InkBlaster) {
|
if (m_InkBlaster) {
|
||||||
|
auto ball = m_World->GetComponent<Components::Ball>(event.Ball);
|
||||||
|
ball->Loaded = true;
|
||||||
m_SquidLoaded = true;
|
m_SquidLoaded = true;
|
||||||
m_AttachedSquid = event.Ball;
|
m_AttachedSquid = event.Ball;
|
||||||
|
|
||||||
|
auto model = m_World->GetComponent<Components::Model>(m_AttachedSquid);
|
||||||
|
model->ModelFile = "Models/Sid/Sid_Shoot.dae";
|
||||||
|
|
||||||
|
auto anim = m_World->GetComponent<Components::Animation>(m_AttachedSquid);
|
||||||
|
anim->Loop = false;
|
||||||
|
anim->Speed = 0.f;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -139,18 +148,32 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
|||||||
transform->Position = event.Position;
|
transform->Position = event.Position;
|
||||||
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||||
m_Shots--;
|
m_Shots--;
|
||||||
|
|
||||||
|
auto anim = m_World->GetComponent<Components::Animation>(m_AttachedSquid);
|
||||||
|
anim->Loop = false;
|
||||||
|
anim->Speed = 1.f;
|
||||||
|
anim->Time = 0.f;
|
||||||
|
|
||||||
if (m_Shots <= 0) {
|
if (m_Shots <= 0) {
|
||||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||||
m_InkBlaster = false;
|
m_InkBlaster = false;
|
||||||
m_SquidLoaded = false;
|
m_SquidLoaded = false;
|
||||||
ball->InkBlaster = false;
|
ball->InkBlaster = false;
|
||||||
ball->Sticky = false;
|
ball->Sticky = false;
|
||||||
|
ball->Loaded = false;
|
||||||
ball->Waiting = true;
|
ball->Waiting = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
Events::InkBlasterOver e;
|
Events::InkBlasterOver e;
|
||||||
e.Ball = m_AttachedSquid;
|
e.Ball = m_AttachedSquid;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
|
auto model = m_World->GetComponent<Components::Model>(m_AttachedSquid);
|
||||||
|
model->ModelFile = "Models/Sid/Sid_Flying.dae";
|
||||||
|
|
||||||
|
auto anim = m_World->GetComponent<Components::Animation>(m_AttachedSquid);
|
||||||
|
anim->Loop = true;
|
||||||
|
anim->Speed = 1.f;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Events::ActionButton e;
|
Events::ActionButton e;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "Game/ScreenShakeSystem.h"
|
#include "Game/ScreenShakeSystem.h"
|
||||||
|
|
||||||
|
|
||||||
void dd::Systems::ScreenShakeSystem::Initialize()
|
void dd::Systems::ScreenShakeSystem::Initialize()
|
||||||
{
|
{
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
|
|||||||
Reference in New Issue
Block a user