Animations

This commit is contained in:
viktorljung
2015-10-22 17:04:19 +02:00
parent 80ba2a0c32
commit 67ef462a53
10 changed files with 3553 additions and 9 deletions
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
+1
View File
@@ -22,6 +22,7 @@ struct Ball : Component
bool Waiting = true;
bool InkBlaster = false;
bool Sticky = false;
bool Loaded = false;
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
};
+1 -1
View File
@@ -145,7 +145,7 @@ private:
bool m_Pause = false;
int m_LooseBricks = 0;
int m_CurrentCluster = 1;
int m_CurrentLevel = 1;
int m_CurrentLevel = 4;
int m_MultiBalls = 0;
int m_PowerUps = 0;
int m_Score = 0;
+1
View File
@@ -28,6 +28,7 @@
#include "Rendering/CSprite.h"
#include <fstream>
#include <iostream>
#include "Rendering/CAnimation.h"
namespace dd
{
+1 -1
View File
@@ -39,7 +39,7 @@ void dd::Systems::BallSystem::Initialize()
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
transform->Orientation = glm::quat();
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);
animation->Speed = 1.0;
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
+12 -7
View File
@@ -112,14 +112,19 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
auto ballTransform = m_World->GetComponent<Components::Transform>(entity);
ballTransform->Position = Transform()->Position;
ballTransform->Position += ball->StickyPlacement;
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
glm::vec2 up = glm::vec2(0.f, 1.f);
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
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 (ball->Loaded) {
ballTransform->Orientation = glm::quat();
} else {
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
glm::vec2 up = glm::vec2(0.f, 1.f);
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
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) {
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
+23
View File
@@ -109,8 +109,17 @@ bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &e
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
{
if (m_InkBlaster) {
auto ball = m_World->GetComponent<Components::Ball>(event.Ball);
ball->Loaded = true;
m_SquidLoaded = true;
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;
}
@@ -139,18 +148,32 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
transform->Position = event.Position;
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
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) {
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
m_InkBlaster = false;
m_SquidLoaded = false;
ball->InkBlaster = false;
ball->Sticky = false;
ball->Loaded = false;
ball->Waiting = true;
{
Events::InkBlasterOver e;
e.Ball = m_AttachedSquid;
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;
+1
View File
@@ -5,6 +5,7 @@
#include "PrecompiledHeader.h"
#include "Game/ScreenShakeSystem.h"
void dd::Systems::ScreenShakeSystem::Initialize()
{
std::random_device rd;