|
|
@ -1,11 +1,11 @@ |
|
|
|
using Microsoft.Xna.Framework; |
|
|
|
using Microsoft.Xna.Framework.Graphics; |
|
|
|
using Microsoft.Xna.Framework.Input; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
namespace SemiColinGames { |
|
|
|
class Player { |
|
|
|
|
|
|
|
enum Facing { Left, Right }; |
|
|
|
enum Pose { Walking, Standing, Crouching, Stretching, SwordSwing, Jumping }; |
|
|
|
enum AirState { Jumping, Ground, Falling }; |
|
|
@ -145,7 +145,7 @@ namespace SemiColinGames { |
|
|
|
position.X = Math.Max(position.X, 0 + spriteWidth); |
|
|
|
} |
|
|
|
|
|
|
|
private int SpritePosition(Pose pose, GameTime time) { |
|
|
|
private int SpriteIndex(Pose pose, GameTime time) { |
|
|
|
int frameNum = (time.TotalGameTime.Milliseconds / 125) % 4; |
|
|
|
if (frameNum == 3) { |
|
|
|
frameNum = 1; |
|
|
@ -180,7 +180,7 @@ namespace SemiColinGames { |
|
|
|
} |
|
|
|
|
|
|
|
public void Draw(SpriteBatch spriteBatch, Camera camera, GameTime time) { |
|
|
|
int index = SpritePosition(pose, time); |
|
|
|
int index = SpriteIndex(pose, time); |
|
|
|
Rectangle textureSource = new Rectangle(index * spriteSize, 0, spriteSize, spriteSize); |
|
|
|
Vector2 spriteCenter = new Vector2(spriteSize / 2, spriteSize / 2); |
|
|
|
SpriteEffects effect = facing == Facing.Right ? |
|
|
|