Optimize
This commit is contained in:
parent
dbdedf48fb
commit
f3353d09e2
3 changed files with 16 additions and 9 deletions
|
@ -812,7 +812,6 @@ int main()
|
||||||
previousTime = timeNow;
|
previousTime = timeNow;
|
||||||
|
|
||||||
int16_t horizontalStep = (dt * PLAYER_SPEED * (player.mRunning ? 2 : 1)) / 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);
|
Vector2D d = angleToDirection(player.mCamera.direction);
|
||||||
|
|
||||||
|
@ -882,8 +881,11 @@ int main()
|
||||||
moveOffset = d;
|
moveOffset = d;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
int16_t rotationStep = (dt * PLAYER_ROTATION_SPEED) / 1000;
|
||||||
player.mCamera.direction += addition * rotationStep;
|
player.mCamera.direction += addition * rotationStep;
|
||||||
|
}
|
||||||
|
|
||||||
Unit prevHeight = player.mCamera.height;
|
Unit prevHeight = player.mCamera.height;
|
||||||
|
|
||||||
moveCameraWithCollision(&player.mCamera,moveOffset,player.mVericalSpeed,
|
moveCameraWithCollision(&player.mCamera,moveOffset,player.mVericalSpeed,
|
||||||
|
|
|
@ -852,7 +852,6 @@ int main()
|
||||||
previousTime = timeNow;
|
previousTime = timeNow;
|
||||||
|
|
||||||
int16_t horizontalStep = (dt * PLAYER_SPEED * (pokitto.bBtn() ? 2 : 1)) / 1000;
|
int16_t horizontalStep = (dt * PLAYER_SPEED * (pokitto.bBtn() ? 2 : 1)) / 1000;
|
||||||
int16_t rotationStep = (dt * PLAYER_ROTATION_SPEED) / 1000;
|
|
||||||
|
|
||||||
Vector2D d = angleToDirection(player.mCamera.direction);
|
Vector2D d = angleToDirection(player.mCamera.direction);
|
||||||
|
|
||||||
|
@ -921,8 +920,11 @@ int main()
|
||||||
moveOffset = d;
|
moveOffset = d;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
int16_t rotationStep = (dt * PLAYER_ROTATION_SPEED) / 1000;
|
||||||
player.mCamera.direction += addition * rotationStep;
|
player.mCamera.direction += addition * rotationStep;
|
||||||
|
}
|
||||||
|
|
||||||
Unit prevHeight = player.mCamera.height;
|
Unit prevHeight = player.mCamera.height;
|
||||||
|
|
||||||
moveCameraWithCollision(&player.mCamera,moveOffset,0,
|
moveCameraWithCollision(&player.mCamera,moveOffset,0,
|
||||||
|
|
13
demo3.cpp
13
demo3.cpp
|
@ -176,8 +176,8 @@ Unit colorAt(int16_t x, int16_t y)
|
||||||
heightProfile[absVal(y) % HEIGHT_PROFILE_LENGTH]) / 10,3);
|
heightProfile[absVal(y) % HEIGHT_PROFILE_LENGTH]) / 10,3);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t previousColumn = 255;
|
uint16_t previousColumn = 255; ///< Helper for precomputing background.
|
||||||
uint16_t backgroundColumn = 0;
|
uint16_t backgroundColumn = 0; ///< Precomputed background column.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Function for drawing a single pixel (like fragment shader).
|
Function for drawing a single pixel (like fragment shader).
|
||||||
|
@ -185,7 +185,6 @@ uint16_t backgroundColumn = 0;
|
||||||
inline void pixelFunc(PixelInfo pixel)
|
inline void pixelFunc(PixelInfo pixel)
|
||||||
{
|
{
|
||||||
uint8_t c = 0;
|
uint8_t c = 0;
|
||||||
|
|
||||||
int16_t intensity = 0;
|
int16_t intensity = 0;
|
||||||
|
|
||||||
if (pixel.isWall)
|
if (pixel.isWall)
|
||||||
|
@ -263,9 +262,11 @@ int main()
|
||||||
|
|
||||||
player.setPositionSquare(4,5);
|
player.setPositionSquare(4,5);
|
||||||
|
|
||||||
|
// init changes
|
||||||
|
|
||||||
for (uint16_t i = 0; i < MAX_CHANGES; ++i)
|
for (uint16_t i = 0; i < MAX_CHANGES; ++i)
|
||||||
{
|
{
|
||||||
changes[i].mCoords.x = i;
|
changes[i].mCoords.x = (i + 1) * 1000;
|
||||||
changes[i].mCoords.y = 0;
|
changes[i].mCoords.y = 0;
|
||||||
changes[i].mHeight = floorHeightAt(i,0);
|
changes[i].mHeight = floorHeightAt(i,0);
|
||||||
}
|
}
|
||||||
|
@ -284,7 +285,6 @@ int main()
|
||||||
previousTime = timeNow;
|
previousTime = timeNow;
|
||||||
|
|
||||||
int16_t horizontalStep = (dt * PLAYER_SPEED * (player.mRunning ? 2 : 1)) / 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);
|
Vector2D d = angleToDirection(player.mCamera.direction);
|
||||||
|
|
||||||
|
@ -421,7 +421,10 @@ int main()
|
||||||
moveOffset = d;
|
moveOffset = d;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
int16_t rotationStep = (dt * PLAYER_ROTATION_SPEED) / 1000;
|
||||||
player.mCamera.direction = wrap(player.mCamera.direction + addition * rotationStep,UNITS_PER_SQUARE);
|
player.mCamera.direction = wrap(player.mCamera.direction + addition * rotationStep,UNITS_PER_SQUARE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editCounter = max(0, editCounter - 1);
|
editCounter = max(0, editCounter - 1);
|
||||||
|
|
Loading…
Reference in a new issue