Browse Source

rename SpritePosition -> SpriteIndex

GitOrigin-RevId: b620c8922b
master
Colin McMillen 4 years ago
parent
commit
ea82c4ffd3
  1. 6
      Shared/Player.cs

6
Shared/Player.cs

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

Loading…
Cancel
Save