Fix controls
This commit is contained in:
parent
2e39b5204b
commit
3287ff2a31
1 changed files with 31 additions and 11 deletions
34
demo3.cpp
34
demo3.cpp
|
@ -35,13 +35,14 @@ public:
|
||||||
uint8_t mColor;
|
uint8_t mColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_CHANGES 32
|
#define MAX_CHANGES 16
|
||||||
|
|
||||||
Change changes[MAX_CHANGES];
|
Change changes[MAX_CHANGES];
|
||||||
|
|
||||||
bool editReleased = false;
|
bool editReleased = false;
|
||||||
bool editing = false;
|
bool editing = false;
|
||||||
uint16_t changeIndex = 0;
|
uint16_t changeIndex = 0;
|
||||||
|
int16_t editCounter = 0;
|
||||||
|
|
||||||
#define HEIGHT_PROFILE_LENGTH 256
|
#define HEIGHT_PROFILE_LENGTH 256
|
||||||
const int8_t heightProfile[] = {
|
const int8_t heightProfile[] = {
|
||||||
|
@ -240,9 +241,9 @@ int main()
|
||||||
|
|
||||||
for (uint16_t i = 0; i < MAX_CHANGES; ++i)
|
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].mCoords.y = 0;
|
||||||
changes[i].mHeight = floorHeightAt(0,0);
|
changes[i].mHeight = floorHeightAt(i,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t previousTime = 0;
|
uint32_t previousTime = 0;
|
||||||
|
@ -322,6 +323,7 @@ int main()
|
||||||
changes[changeIndex].mCoords.x = selectedSquare.x;
|
changes[changeIndex].mCoords.x = selectedSquare.x;
|
||||||
changes[changeIndex].mCoords.y = selectedSquare.y;
|
changes[changeIndex].mCoords.y = selectedSquare.y;
|
||||||
editReleased = false;
|
editReleased = false;
|
||||||
|
editCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -331,7 +333,13 @@ int main()
|
||||||
{
|
{
|
||||||
if (editing)
|
if (editing)
|
||||||
{
|
{
|
||||||
changes[changeIndex].mHeight += 100;
|
if (editCounter == 0)
|
||||||
|
{
|
||||||
|
changes[changeIndex].mHeight += UNITS_PER_SQUARE / 4;
|
||||||
|
editCounter = 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
editCounter--;
|
||||||
}
|
}
|
||||||
else if (aButton)
|
else if (aButton)
|
||||||
player.mCamera.shear = min(player.mCamera.shear + 10,60);
|
player.mCamera.shear = min(player.mCamera.shear + 10,60);
|
||||||
|
@ -342,7 +350,13 @@ int main()
|
||||||
{
|
{
|
||||||
if (editing)
|
if (editing)
|
||||||
{
|
{
|
||||||
changes[changeIndex].mHeight -= 100;
|
if (editCounter == 0)
|
||||||
|
{
|
||||||
|
changes[changeIndex].mHeight -= UNITS_PER_SQUARE / 4;
|
||||||
|
editCounter = 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
editCounter--;
|
||||||
}
|
}
|
||||||
else if (aButton)
|
else if (aButton)
|
||||||
player.mCamera.shear = max(player.mCamera.shear - 10,-60);
|
player.mCamera.shear = max(player.mCamera.shear - 10,-60);
|
||||||
|
@ -353,17 +367,23 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
player.mCamera.shear /= 2;
|
player.mCamera.shear /= 2;
|
||||||
|
editCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!aButton)
|
if (!aButton)
|
||||||
player.mCamera.shear /= 2;
|
player.mCamera.shear /= 2;
|
||||||
|
|
||||||
int addition = 0;
|
int addition = 0;
|
||||||
|
|
||||||
|
if (!editing)
|
||||||
|
{
|
||||||
if (pokitto.rightBtn())
|
if (pokitto.rightBtn())
|
||||||
addition = 1;
|
addition = 1;
|
||||||
else if (pokitto.leftBtn())
|
else if (pokitto.leftBtn())
|
||||||
addition = -1;
|
addition = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (aButton)
|
if (aButton)
|
||||||
{
|
{
|
||||||
|
@ -384,9 +404,9 @@ int main()
|
||||||
Unit heightDiff = player.mCamera.height - prevHeight;
|
Unit heightDiff = player.mCamera.height - prevHeight;
|
||||||
|
|
||||||
if (heightDiff == 0)
|
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 camX = divRoundDown(player.mCamera.position.x,UNITS_PER_SQUARE);
|
||||||
int16_t camY = divRoundDown(player.mCamera.position.y,UNITS_PER_SQUARE);
|
int16_t camY = divRoundDown(player.mCamera.position.y,UNITS_PER_SQUARE);
|
||||||
|
|
Loading…
Reference in a new issue