public Sprite(Vector2 pos, Vector2 dim, SpriteBatch sprite, Texture2D txt, Vector2 subTopleft, Vector2 subDim, int rows, int columns, float spriteLayer, float delay = 0.1f) { position = new Rectangle(pos.ToPoint(), dim.ToPoint()); spriteBatch = sprite; texture = txt; layer = spriteLayer; numFrames = rows * columns; frameChange = ISprite.FrameChange.Forward; frameTimer = frameDelay / 2; currentFrame = 0; LoadFrames(rows, columns, subTopleft, subDim); frameDelay = delay; }
// sum(i:[0,|frameProbabilities|),frameProbabilities[i]) = 1 public RandomSprite(Vector2 pos, Vector2 dim, SpriteBatch sprite, Texture2D txt, Vector2 subTopleft, Vector2 subDim, int rows, int columns, float spriteLayer, List <double> frameProbabilities, int seed, float delay = 0.3f) { position = new Rectangle(pos.ToPoint(), dim.ToPoint()); spriteBatch = sprite; texture = txt; layer = spriteLayer; frameChange = ISprite.FrameChange.Changing; frameTimer = 0; frameDelay = delay; currentFrame = 0; LoadFrames(rows, columns, subTopleft, subDim); frameCumulativeProbabilities = frameProbabilities; rd = new Random(seed); for (int i = 1; i < frameCumulativeProbabilities.Count; i++) { frameCumulativeProbabilities[i] += frameCumulativeProbabilities[i - 1]; } }