summaryrefslogtreecommitdiffstats
path: root/matchblox/engine/C_Block.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'matchblox/engine/C_Block.cpp')
-rw-r--r--matchblox/engine/C_Block.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/matchblox/engine/C_Block.cpp b/matchblox/engine/C_Block.cpp
index 4c092a2..81d3b66 100644
--- a/matchblox/engine/C_Block.cpp
+++ b/matchblox/engine/C_Block.cpp
@@ -1,13 +1,14 @@
#include <GL/glut.h>
#include <iostream>
-
+#define _USE_MATH_DEFINES
+#include <math.h>
#include "C_Block.h"
#define FADE_DURATION 500
/*Durations of animations*/
-unsigned int g_BlockAnimDurations[4] = {0, 500, 500, 500};
+unsigned int g_BlockAnimDurations[4] = {0, 500, 500, 100};
C_Block::C_Block(const char* f_strFileName,
GLuint f_uiColorTex ,
@@ -26,7 +27,7 @@ C_Block::~C_Block()
void C_Block::Render(unsigned int f_iElapsedTime)
{
unsigned int l_uiDeltaTime = f_iElapsedTime - m_uiAnimStart;
- double l_Scale = 0.0;
+ double l_Scale, l_Scalexz, l_Frac;
//check if the previous animation has ended in between
@@ -56,11 +57,19 @@ void C_Block::Render(unsigned int f_iElapsedTime)
C_3DObject::Render();
break;
- case BS_COLLIDE:
+ case BS_COLLIDE: //wobble
+ l_Frac = ((double)l_uiDeltaTime / (double)g_BlockAnimDurations[BS_COLLIDE]);
+ l_Frac *= (M_PI/2.0);
+ l_Scale = 0.8 + cos(l_Frac)*0.2;
+ l_Scalexz = 1.0 - sin(l_Frac)*0.2;
+ SetScale(l_Scalexz, l_Scale, l_Scalexz);
+ TransRotateScale();
+ C_3DObject::Render();
break;
case BS_IDLE:
default:
+ SetScale(1.0, 1.0, 1.0);
TransRotateScale();
C_3DObject::Render();
break;