|
|
@ -5,12 +5,6 @@ using System.Collections.Generic; |
|
|
|
|
|
|
|
namespace SemiColinGames { |
|
|
|
class Player { |
|
|
|
// The player's Facing corresponds to the x-direction that they're looking.
|
|
|
|
enum Facing { |
|
|
|
Left = -1, |
|
|
|
Right = 1 |
|
|
|
}; |
|
|
|
|
|
|
|
public enum Pose { Walking, Standing, Crouching, Stretching, SwordSwing, Jumping }; |
|
|
|
|
|
|
|
private const int moveSpeed = 180; |
|
|
@ -35,7 +29,6 @@ namespace SemiColinGames { |
|
|
|
private Vector2 eyeOffsetWalking = new Vector2(15, -7); |
|
|
|
|
|
|
|
private int jumps = 0; |
|
|
|
private Facing facing = Facing.Right; |
|
|
|
private Pose pose = Pose.Jumping; |
|
|
|
private double swordSwingTime = 0; |
|
|
|
private int swordSwingNum = 0; |
|
|
@ -46,10 +39,7 @@ namespace SemiColinGames { |
|
|
|
this.texture = texture; |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: just make Facing an int.
|
|
|
|
public int GetFacing { |
|
|
|
get { return (int) facing; } |
|
|
|
} |
|
|
|
public int Facing { get; private set; } = 1; |
|
|
|
|
|
|
|
public Pose GetPose { |
|
|
|
get { return pose; } |
|
|
@ -139,9 +129,9 @@ namespace SemiColinGames { |
|
|
|
} |
|
|
|
|
|
|
|
if (movement.X > 0) { |
|
|
|
facing = Facing.Right; |
|
|
|
Facing = 1; |
|
|
|
} else if (movement.X < 0) { |
|
|
|
facing = Facing.Left; |
|
|
|
Facing = -1; |
|
|
|
} |
|
|
|
if (swordSwingTime > 0) { |
|
|
|
pose = Pose.SwordSwing; |
|
|
@ -163,7 +153,7 @@ namespace SemiColinGames { |
|
|
|
bool walking = pose == Pose.Walking || pose == Pose.Jumping; |
|
|
|
Vector2 eyeOffset = walking ? eyeOffsetWalking : eyeOffsetStanding; |
|
|
|
return Vector2.Add( |
|
|
|
Position.ToVector2(), new Vector2(eyeOffset.X * (int) facing, eyeOffset.Y)); |
|
|
|
Position.ToVector2(), new Vector2(eyeOffset.X * Facing, eyeOffset.Y)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -220,7 +210,7 @@ namespace SemiColinGames { |
|
|
|
int index = SpriteIndex(pose); |
|
|
|
Rectangle textureSource = new Rectangle(index * spriteWidth, 0, spriteWidth, spriteHeight); |
|
|
|
Vector2 spriteCenter = new Vector2(spriteWidth / 2, spriteHeight / 2 + spriteCenterYOffset); |
|
|
|
SpriteEffects effect = facing == Facing.Right ? |
|
|
|
SpriteEffects effect = Facing == 1 ? |
|
|
|
SpriteEffects.FlipHorizontally : SpriteEffects.None; |
|
|
|
spriteBatch.Draw(texture, position.ToVector2(), textureSource, Color.White, 0f, spriteCenter, |
|
|
|
Vector2.One, effect, 0f); |
|
|
|