1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
/***************************************************************************
KeyBeh.cpp - description
-------------------
begin : Wed Jan 26 2000
copyright : (C) 2000 by Henrik Enqvist
email : henqvist@excite.com
***************************************************************************/
#include "Private.h"
#include "KeyBehavior.h"
#include "Group.h"
#include "Shape3D.h"
#include "Keyboard.h"
KeyBehavior::KeyBehavior() : Behavior() {
m_x = 0;
m_y = 0;
m_z = 0;
}
KeyBehavior::~KeyBehavior() {
}
void KeyBehavior::onTick() {
EmAssert(this->getParent() != NULL, "KeyBehavior::onTick parent NULL");
m_x = this->getParent()->m_mtxSrc.t[0];
m_y = this->getParent()->m_mtxSrc.t[1];
m_z = this->getParent()->m_mtxSrc.t[2];
if (Keyboard::isKeyDown(SDLK_a)) m_x -= 0.2;
if (Keyboard::isKeyDown(SDLK_d)) m_x += 0.2;
if (Keyboard::isKeyDown(SDLK_w)) m_z -= 0.2;
if (Keyboard::isKeyDown(SDLK_s)) m_z += 0.2;
if (Keyboard::isKeyDown(SDLK_q)) m_y -= 0.2;
if (Keyboard::isKeyDown(SDLK_e)) m_y += 0.2;
this->getParent()->setTranslation(m_x, m_y, m_z);
}
|