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; using Microsoft.Xna.Framework.Input; using System.IO; namespace Colto1 { class Level1 { Texture2D backgroundImage; Game1 parent; Animal animal; Rectangle location = new Rectangle(0, 0, 1024, 768); public int[] xs = { 300, 500, 700 }; public int floor = 700, floorup=600; public Level1(Game1 parent, int w, int h) { this.parent = parent; animal = new Animal(this); location.Width = w; location.Height= h; xs = new int[] {w*1/3, w/2, w*2/3 }; floor = h * 8 / 10; floorup = h * 7 / 10; } public void LoadContent(ContentManager manager, string filename){ backgroundImage = manager.Load(filename); animal.LoadContent(manager, "01"); } public void Update() { KeyboardState state=Keyboard.GetState(); animal.speed.X=0; animal.speed.Y=0; if (state.IsKeyDown(Keys.Left)) { animal.speed.X = -1; } if (state.IsKeyDown(Keys.Right)) { animal.speed.X = 1; } if (state.IsKeyDown(Keys.Up)) { animal.speed.Y = -1; } if (state.IsKeyDown(Keys.Down)) { animal.speed.Y = 1; } animal.Update(); } public void Draw(SpriteBatch batch) { batch.Draw(backgroundImage, location, Color.White); animal.Draw(batch); } } }