From 4758ce519b68d8fe071b4f1b6852dca8243c031b Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Mon, 3 Feb 2020 09:03:44 -0500 Subject: [PATCH] allow player to look up/down GitOrigin-RevId: 00041d67360a610ff032a0ab0ea5826e091f1c90 --- Shared/Player.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Shared/Player.cs b/Shared/Player.cs index 2675865..e7db54c 100644 --- a/Shared/Player.cs +++ b/Shared/Player.cs @@ -181,6 +181,12 @@ namespace SemiColinGames { float visionRange = 150; float visionRangeSq = visionRange * visionRange; Vector2 ray = new Vector2(visionRange * (int) facing, 0); + if (pose == Pose.Stretching) { + ray = Rotate(ray, FMath.DegToRad(-30)); + } + if (pose == Pose.Crouching) { + ray = Rotate(ray, FMath.DegToRad(30)); + } Vector2 coneBottom = Rotate(ray, fov); Vector2 coneTop = Rotate(ray, -fov); @@ -259,16 +265,11 @@ namespace SemiColinGames { private int SpriteIndex(Pose pose) { int frameNum = (int) Clock.ModelTime.TotalMilliseconds / 125 % 4; - if (frameNum == 3 && pose == Pose.Standing) { - frameNum = 1; - } switch (pose) { case Pose.Walking: return 35 + frameNum; case Pose.Jumping: return 35 + frameNum; - case Pose.Stretching: - return (int) Clock.ModelTime.TotalMilliseconds / 125 % 2; case Pose.SwordSwing: if (swordSwingTime > 0.2) { return 0 + swordSwingNum * 3; @@ -278,10 +279,14 @@ namespace SemiColinGames { return 2 + swordSwingNum * 3; } case Pose.Crouching: - return 26; + case Pose.Stretching: case Pose.Standing: - default: - return 29 + frameNum; + default: { + if (frameNum == 3) { + frameNum = 1; + } + return 29 + frameNum; + } } }