using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace BouncyCatIsBouncy { class Yarn : IDynamicObject { Texture2D m_texture; Vector2 m_position, m_offset, m_origin; SpriteBatch m_batch; float m_totalTime; public Yarn(SpriteBatch batch, Vector2 position) { m_batch = batch; m_position = position; } public void Draw() { m_batch.Draw(m_texture, m_position + m_offset, null, Color.White, 0.0f, m_origin, 0.5f, SpriteEffects.None, 1.0f); } public void LoadContent(ContentManager manager) { m_texture = manager.Load(@"Spritesheets/yarn"); m_origin = new Vector2(m_texture.Width / 3.5f, m_texture.Height / 2.0f); } public void Update(float dt) { m_totalTime += dt; m_offset.Y = (float)Math.Cos(m_totalTime / 500.0f) * 15.0f; } } }