using System; using System.Collections.Generic; using System.Linq; using System.Text; //using System. using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Audio; namespace Colto1 { class Word { public string value=""; public string answer=""; //Texture2D image; public Vector2 position = new Vector2(250, 150); public Vector2 size=new Vector2(100, 100); public Vector2 speed = new Vector2(0, 0.3f); static SpriteFont font; float angle = 45; static string[] filenames = { "par_left", "par_mid", "par_right" }; static Texture2D[] images=new Texture2D[filenames.Length]; public int ImageNr = 0; static Random r = new Random(); Level1 parent; public Word(Level1 parent, string value) { this.parent = parent; this.value = value; chooseRandomImage(); } public static void LoadContent(ContentManager manager) { /*Random r=new Random(); string randomfile=filenames[r.Next(filenames.Length)]; image = manager.Load(randomfile);*/ for (int i = 0; i < filenames.Length; i++) { images[i] = manager.Load(filenames[i]); } //font = new Font("Arial Unicode MS", 18, FontStyle.Regular); font = manager.Load("SpriteFont1"); } public void Update() { position.X += speed.X; position.Y += speed.Y; angle+=(float)0.05; } public void Draw(SpriteBatch batch) { float drawingangle = (float)(Math.Sin(angle)*0.2); Vector2 center = new Vector2(images[ImageNr].Width / 2, images[ImageNr].Height); Vector2 imageposition = new Vector2(position.X, position.Y); batch.Draw(images[ImageNr], imageposition, null, Color.White, drawingangle, center, (float)(size.Y * 0.75 / images[ImageNr].Width), SpriteEffects.None, 0); Vector2 wordposition = new Vector2(position.X+2, position.Y + 6); Vector2 wordcenter = new Vector2(font.MeasureString(this.value).X / 2, 18); //batch.DrawString(font, value, wordposition, Color.White); batch.DrawString(font, value, wordposition, Color.DarkMagenta, drawingangle, wordcenter, 1, SpriteEffects.None, 0); batch.DrawString(font, value, imageposition, Color.White, drawingangle, wordcenter, 1, SpriteEffects.None, 0); } public void chooseRandomImage() { ImageNr = r.Next(filenames.Length); speed.Y = (float)(0.2+r.NextDouble()*0.1); angle = r.Next(90); } } }