public AnimatedSprite(Texture2D texture, SpriteInfo spriteInfo, Vector2 position, bool randomStartFrame = false) : base(texture, position) { _spriteInfo = spriteInfo; _timer = new GameTimer(TimeSpan.FromSeconds((double) 1/spriteInfo.FramesPerSecond)); _frameWidth = (float) Texture.Width/_spriteInfo.ColCount; _frameHeight = (float) Texture.Height/_spriteInfo.RowCount; if (randomStartFrame) _currentFrame = new Random().Next(_spriteInfo.FrameCount - 1); _framesRectangles = new Rectangle[_spriteInfo.FrameCount]; InitFramesRectangles(); }
public Sprite GetAcceleratorSprite() { if (_acceleratorTexture == null) return GetDefaultSprite(); var spriteInfo = new SpriteInfo { FrameCount = 7, RowCount = 1, ColCount = 7, FramesPerSecond = 4 }; return new AnimatedSprite(_acceleratorTexture, spriteInfo, Vector2.Zero, true); }
public AnimatedSprite(Texture2D texture, SpriteInfo spriteInfo) : this(texture, spriteInfo, Vector2.Zero) { }
public Sprite GetBallSprite(int index) { if (_ballsTextures == null) return GetDefaultSprite(); var ballSpriteInfo = new SpriteInfo { FrameCount = 9, RowCount = 1, ColCount = 9, FramesPerSecond = 15 }; switch (index) { case 0: { var spriteInfo = new SpriteInfo { FrameCount = 15, RowCount = 3, ColCount = 5, FramesPerSecond = 15 }; return new AnimatedSprite(_ballsTextures[0], spriteInfo, Vector2.Zero, true); } case 1: case 2: case 3: case 4: return new AnimatedSprite(_ballsTextures[index], ballSpriteInfo, Vector2.Zero, true); } throw new IndexOutOfRangeException(); }
public Sprite GetTimeBonusSprite() { if (_timeBonusTexture == null) return GetDefaultSprite(); var spriteInfo = new SpriteInfo { FrameCount = 12, RowCount = 2, ColCount = 6, FramesPerSecond = 4 }; return new AnimatedSprite(_timeBonusTexture, spriteInfo, Vector2.Zero, true); }
public Sprite GetScoresBonusSprite() { if (_scoresBonusTexture == null) return GetDefaultSprite(); var spriteInfo = new SpriteInfo { FrameCount = 64, RowCount = 8, ColCount = 8, FramesPerSecond = 40 }; return new AnimatedSprite(_scoresBonusTexture, spriteInfo, Vector2.Zero, true); }
public Sprite GetMineSprite() { if (_mineTexture == null) return GetDefaultSprite(); var spriteInfo = new SpriteInfo { FrameCount = 30, RowCount = 3, ColCount = 10, FramesPerSecond = 25 }; return new AnimatedSprite(_mineTexture, spriteInfo, Vector2.Zero, true); }
public Sprite GetMainDeviceSprite() { if (_mainDeviceTexture == null) return GetDefaultSprite(); var spriteInfo = new SpriteInfo { FrameCount = 71, RowCount = 5, ColCount = 16, FramesPerSecond = 40 }; return new AnimatedSprite(_mainDeviceTexture, spriteInfo, Vector2.Zero, true); }
public Sprite GetExplosionSprite(int index) { if (_explosionTextures == null) return GetDefaultSprite(); if (index == 0) { var spriteInfo = new SpriteInfo { FrameCount = 40, RowCount = 5, ColCount = 8, FramesPerSecond = 40 }; return new AnimatedSprite(_explosionTextures[0], spriteInfo); } throw new NotSupportedException(); }