allow player to look up/down

GitOrigin-RevId: 00041d67360a610ff032a0ab0ea5826e091f1c90
This commit is contained in:
Colin McMillen 2020-02-03 09:03:44 -05:00
parent 1f7da03515
commit 4758ce519b

View File

@ -181,6 +181,12 @@ namespace SemiColinGames {
float visionRange = 150; float visionRange = 150;
float visionRangeSq = visionRange * visionRange; float visionRangeSq = visionRange * visionRange;
Vector2 ray = new Vector2(visionRange * (int) facing, 0); 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 coneBottom = Rotate(ray, fov);
Vector2 coneTop = Rotate(ray, -fov); Vector2 coneTop = Rotate(ray, -fov);
@ -259,16 +265,11 @@ namespace SemiColinGames {
private int SpriteIndex(Pose pose) { private int SpriteIndex(Pose pose) {
int frameNum = (int) Clock.ModelTime.TotalMilliseconds / 125 % 4; int frameNum = (int) Clock.ModelTime.TotalMilliseconds / 125 % 4;
if (frameNum == 3 && pose == Pose.Standing) {
frameNum = 1;
}
switch (pose) { switch (pose) {
case Pose.Walking: case Pose.Walking:
return 35 + frameNum; return 35 + frameNum;
case Pose.Jumping: case Pose.Jumping:
return 35 + frameNum; return 35 + frameNum;
case Pose.Stretching:
return (int) Clock.ModelTime.TotalMilliseconds / 125 % 2;
case Pose.SwordSwing: case Pose.SwordSwing:
if (swordSwingTime > 0.2) { if (swordSwingTime > 0.2) {
return 0 + swordSwingNum * 3; return 0 + swordSwingNum * 3;
@ -278,10 +279,14 @@ namespace SemiColinGames {
return 2 + swordSwingNum * 3; return 2 + swordSwingNum * 3;
} }
case Pose.Crouching: case Pose.Crouching:
return 26; case Pose.Stretching:
case Pose.Standing: case Pose.Standing:
default: default: {
return 29 + frameNum; if (frameNum == 3) {
frameNum = 1;
}
return 29 + frameNum;
}
} }
} }