diff --git a/demo1.cpp b/demo1.cpp index 44ef89e..43d5920 100644 --- a/demo1.cpp +++ b/demo1.cpp @@ -688,6 +688,8 @@ pokitto.display.print(player.mCamera.direction); */ } +bool runReleased = false; + int main() { pokitto.begin(); @@ -716,7 +718,7 @@ int main() dt = timeNow - previousTime; previousTime = timeNow; - int16_t horizontalStep = (dt * PLAYER_SPEED) / 1000; + int16_t horizontalStep = (dt * PLAYER_SPEED * (player.mRunning ? 2 : 1)) / 1000; int16_t rotationStep = (dt * PLAYER_ROTATION_SPEED) / 1000; Vector2D d = angleToDirection(player.mCamera.direction); @@ -735,19 +737,29 @@ int main() d.y = d.y > 0 ? horizontalStep : -1 * horizontalStep; } - bool strafe = pokitto.aBtn(); - bool lookUpDown = pokitto.cBtn(); + bool aButton = pokitto.aBtn(); + + if (pokitto.cBtn()) + { + if (runReleased) + { + player.mRunning = !player.mRunning; + runReleased = false; + } + } + else + runReleased = true; if (pokitto.upBtn()) { - if (lookUpDown) + if (aButton) player.mCamera.shear = min(player.mCamera.shear + 10,60); else moveOffset = d; } else if (pokitto.downBtn()) { - if (lookUpDown) + if (aButton) player.mCamera.shear = max(player.mCamera.shear - 10,-60); else { @@ -758,7 +770,7 @@ int main() else player.mCamera.shear /= 2; - if (!lookUpDown) + if (!aButton) player.mCamera.shear /= 2; int addition = 0; @@ -768,7 +780,7 @@ int main() else if (pokitto.leftBtn()) addition = -1; - if (strafe) + if (aButton) { d = angleToDirection(player.mCamera.direction + UNITS_PER_SQUARE / 4); d.x = (d.x * horizontalStep * addition) / UNITS_PER_SQUARE; diff --git a/general.hpp b/general.hpp index db2534f..43d62c0 100644 --- a/general.hpp +++ b/general.hpp @@ -168,6 +168,7 @@ class Player public: Camera mCamera; Unit mVericalSpeed; + bool mRunning; Player() { @@ -179,6 +180,7 @@ public: mCamera.resolution.y = SCREEN_HEIGHT; mCamera.shear = 0; mVericalSpeed = 0; + mRunning = false; } void setPosition(Unit x, Unit y)