From 3287ff2a31a204efdc2caf6df7eeaf4c4c352f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Mon, 10 Sep 2018 15:34:01 +0200 Subject: [PATCH] Fix controls --- demo3.cpp | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/demo3.cpp b/demo3.cpp index 2124541..f9c0d49 100644 --- a/demo3.cpp +++ b/demo3.cpp @@ -35,13 +35,14 @@ public: uint8_t mColor; }; -#define MAX_CHANGES 32 +#define MAX_CHANGES 16 Change changes[MAX_CHANGES]; bool editReleased = false; bool editing = false; uint16_t changeIndex = 0; +int16_t editCounter = 0; #define HEIGHT_PROFILE_LENGTH 256 const int8_t heightProfile[] = { @@ -240,9 +241,9 @@ int main() for (uint16_t i = 0; i < MAX_CHANGES; ++i) { - changes[i].mCoords.x = 0; + changes[i].mCoords.x = i; changes[i].mCoords.y = 0; - changes[i].mHeight = floorHeightAt(0,0); + changes[i].mHeight = floorHeightAt(i,0); } uint32_t previousTime = 0; @@ -322,6 +323,7 @@ int main() changes[changeIndex].mCoords.x = selectedSquare.x; changes[changeIndex].mCoords.y = selectedSquare.y; editReleased = false; + editCounter = 0; } } else @@ -331,7 +333,13 @@ int main() { if (editing) { - changes[changeIndex].mHeight += 100; + if (editCounter == 0) + { + changes[changeIndex].mHeight += UNITS_PER_SQUARE / 4; + editCounter = 4; + } + else + editCounter--; } else if (aButton) player.mCamera.shear = min(player.mCamera.shear + 10,60); @@ -342,7 +350,13 @@ int main() { if (editing) { - changes[changeIndex].mHeight -= 100; + if (editCounter == 0) + { + changes[changeIndex].mHeight -= UNITS_PER_SQUARE / 4; + editCounter = 4; + } + else + editCounter--; } else if (aButton) player.mCamera.shear = max(player.mCamera.shear - 10,-60); @@ -353,17 +367,23 @@ int main() } } else + { player.mCamera.shear /= 2; + editCounter = 0; + } if (!aButton) player.mCamera.shear /= 2; int addition = 0; - if (pokitto.rightBtn()) - addition = 1; - else if (pokitto.leftBtn()) - addition = -1; + if (!editing) + { + if (pokitto.rightBtn()) + addition = 1; + else if (pokitto.leftBtn()) + addition = -1; + } if (aButton) { @@ -384,9 +404,9 @@ int main() Unit heightDiff = player.mCamera.height - prevHeight; if (heightDiff == 0) - player.mVericalSpeed = 0; // hit floor/ceiling + player.mVericalSpeed = 0; // hit floor - if (player.mVericalSpeed == 0 && pokitto.bBtn()) + if (!editing && player.mVericalSpeed == 0 && pokitto.bBtn()) { int16_t camX = divRoundDown(player.mCamera.position.x,UNITS_PER_SQUARE); int16_t camY = divRoundDown(player.mCamera.position.y,UNITS_PER_SQUARE);