summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2011-11-28 17:31:22 +0100
committerDominique Martinet <asmadeus@codewreck.org>2011-11-28 17:31:22 +0100
commite7cfc50df604e0751b3e3638e15504e4b2379894 (patch)
treed5be89afb118de3d6d8b6384591c084e1e45558b
parente49f4b2329ee5acd59e681c1a67549685cf78054 (diff)
Player: turnLeft(), turnRight()
-rw-r--r--Player.cpp13
-rw-r--r--Player.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/Player.cpp b/Player.cpp
index 618aae1..370bf4f 100644
--- a/Player.cpp
+++ b/Player.cpp
@@ -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);
diff --git a/Player.h b/Player.h
index 16b4753..3815f0c 100644
--- a/Player.h
+++ b/Player.h
@@ -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();