Add shearing

This commit is contained in:
Miloslav Číž 2018-09-07 20:33:38 +02:00
parent cee662ed6b
commit 6307d48599

View file

@ -767,6 +767,8 @@ inline void pixelFunc(PixelInfo pixel)
unsigned short pal[256];
Unit shear = 0;
void draw()
{
RayConstraints c;
@ -775,7 +777,7 @@ void draw()
c.maxSteps = 10;
c.computeTextureCoords = 1;
render(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,pixelFunc,c);
render(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,pixelFunc,c,shear);
Unit previousDepth;
@ -868,11 +870,14 @@ int main()
}
bool strafe = p.aBtn();
bool lookUpDown = p.cBtn();
if (p.upBtn())
{
if (strafe)
heightOffset = step;
else if (lookUpDown)
shear = min(shear + 100, 2 * UNITS_PER_SQUARE);
else
moveOffset = d;
}
@ -880,6 +885,8 @@ int main()
{
if (strafe)
heightOffset = -step;
else if (lookUpDown)
shear = max(shear - 100, -2 * UNITS_PER_SQUARE);
else
{
moveOffset.x = -1 * d.x;
@ -887,6 +894,9 @@ int main()
}
}
if (!lookUpDown)
shear = shear / 2;
int addition = 0;
if (p.rightBtn())
@ -904,7 +914,7 @@ int main()
}
else
player.mCamera.direction += addition * step2;
moveCameraWithCollision(&player.mCamera,moveOffset,heightOffset,
floorHeightAt, ceilingHeightAt);
}