using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Audio; namespace Colto1 { class Animal { Level1 parent; Texture2D animalImage; //Vector2 location=new Vector2(100, 100); Rectangle location = new Rectangle(300, 450, 100, 150); public Vector2 speed = new Vector2(0, 0); public Animal(Level1 parent) { this.parent = parent; } public void LoadContent(ContentManager manager, string filename) { animalImage = manager.Load(filename); } public void Update() { // location += new Vector2(1, 0); if (location.Y > parent.floorup && location.Y < parent.floor) { location.X += (int)speed.X; } if (location.Y <= parent.floorup) { if (location.X < (parent.xs[0] + parent.xs[1]) / 2) { location.X = parent.xs[0]; } else if (location.X >= (parent.xs[1] + parent.xs[2]) / 2) { location.X = parent.xs[2]; } else { location.X = parent.xs[1]; } } location.Y += (int)speed.Y; if (location.Y > parent.floor) { location.Y = parent.floor; } } public void Draw(SpriteBatch batch) { batch.Draw(animalImage, location, Color.White); } } }