From 6307d4859990f3fdbe8bf675f7c8596a50d62f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Fri, 7 Sep 2018 20:33:38 +0200 Subject: [PATCH] Add shearing --- game.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/game.cpp b/game.cpp index d5784d7..c967b26 100644 --- a/game.cpp +++ b/game.cpp @@ -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); }