diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2011-11-28 17:31:22 +0100 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2011-11-28 17:31:22 +0100 |
commit | e7cfc50df604e0751b3e3638e15504e4b2379894 (patch) | |
tree | d5be89afb118de3d6d8b6384591c084e1e45558b | |
parent | e49f4b2329ee5acd59e681c1a67549685cf78054 (diff) |
Player: turnLeft(), turnRight()
-rw-r--r-- | Player.cpp | 13 | ||||
-rw-r--r-- | Player.h | 2 |
2 files changed, 15 insertions, 0 deletions
@@ -28,6 +28,19 @@ void Player::setVelocityVector(VelocityVector v) { m_velocityVector = v;
}
+void Player::turnLeft() {
+ uint t = m_velocityVector.x;
+ m_velocityVector.x = m_velocityVector.y;
+ m_velocityVector.y = - m_velocityVector.x;
+}
+
+void Player::turnRight() {
+ uint t = m_velocityVector.x;
+ m_velocityVector.x = - m_velocityVector.y;
+ m_velocityVector.y = m_velocityVector.x;
+}
+
+
bool Player::changeDirection(VelocityVector v) {
if ((m_velocityVector.x != 0 && v.x != 0) || (m_velocityVector.y != 0 && v.y != 0)) {
return(false);
@@ -27,6 +27,8 @@ public: * or the same way. Only possible change is 90°.
**/
bool changeDirection(VelocityVector v);
+ void turnLeft();
+ void turnRight();
bool isAlive();
void kill();
|