rename SpritePosition -> SpriteIndex

GitOrigin-RevId: b620c8922b92ac9f5b1b4298dfa9ed35a7641f11
This commit is contained in:
Colin McMillen 2020-01-17 19:33:52 -05:00
parent 03b8688f1e
commit ea82c4ffd3

View File

@ -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 ?