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