protected override void Update(GameTime gameTime) { // Allows the game to exit by pressing if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) this.Exit(); //new MouseState mymouse MouseState myMouse = Mouse.GetState(); //new keyboardstate state KeyboardState state = Keyboard.GetState(); // soundEffectInstance.Play(); if (gameState == GameState.Menu)//if gamestate equals menu { if (myMouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && webrec.Contains(myMouse.X, myMouse.Y)) { webcloudc = true; filecloudc = false; } if (myMouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && filegenrec.Contains(myMouse.X, myMouse.Y) || state.IsKeyDown(Keys.Enter)) { //GAVIN PUT THE GAMESTATE CHANGE HERE TO EXIT FROM MENU TO GAME startweb = true; gameState = GameState.Game;//gamestate equals game soundEffectInstance.Play(); } if (myMouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && webgenrec.Contains(myMouse.X, myMouse.Y) || state.IsKeyDown(Keys.Enter)) { using (StreamWriter writer = new StreamWriter("thisonelads2.txt")) { writer.Write(webaddress); } startweb = true; //GAVING PUT THE GAMESTATECHANGE HERE TO EXIT FROM MENU TO GAME gameState = GameState.Game;//gamestate equals game soundEffectInstance.Play(); } if (webcloudc == true) { if ((webaddress.Length) < (starter.Length)) { webaddress = starter; } /*I HATE THIS SECTION BUT I COULDNT FIND A WAY TO ALLOW ME TO DO A ARRAY OF KEYS AND IMPLEMENT A FOREACH LOOP*/ if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.OemPeriod)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemPeriod))) { webaddress = webaddress + "."; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.OemQuestion)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemQuestion))) { webaddress = webaddress + "/"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Q)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Q))) { webaddress = webaddress + "q"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.W)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.W))) { webaddress = webaddress + "w"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.E)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.E))) { webaddress = webaddress + "e"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.R)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.R))) { webaddress = webaddress + "r"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.T)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.T))) { webaddress = webaddress + "t"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Y)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Y))) { webaddress = webaddress + "y"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.U)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.U))) { webaddress = webaddress + "I"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.I)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I))) { webaddress = webaddress + "i"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.O)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.O))) { webaddress = webaddress + "o"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.P)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.P))) { webaddress = webaddress + "p"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.A)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.A))) { webaddress = webaddress + "a"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.S)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.S))) { webaddress = webaddress + "s"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.D)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D))) { webaddress = webaddress + "d"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.F)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F))) { webaddress = webaddress + "f"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.G)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.G))) { webaddress = webaddress + "g"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.H)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.H))) { webaddress = webaddress + "h"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.J)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.J))) { webaddress = webaddress + "j"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.K)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.K))) { webaddress = webaddress + "k"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.L)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.L))) { webaddress = webaddress + "l"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Z)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Z))) { webaddress = webaddress + "z"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.X)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X))) { webaddress = webaddress + "x"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.C)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C))) { webaddress = webaddress + "c"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.V)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V))) { webaddress = webaddress + "v"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.B)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.B))) { webaddress = webaddress + "b"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.N)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.N))) { webaddress = webaddress + "n"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.M)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.M))) { webaddress = webaddress + "m"; } if ((oldstate.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Back)) && (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back)) && (webaddress.Length > 0)) { webaddress2 = webaddress.Substring(0, webaddress.Length - 1); webaddress = webaddress2; updateaddress = true; } oldstate = state; } if (myMouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && filerec.Contains(myMouse.X, myMouse.Y) && (filecloudc == false)) { webcloudc = false; filecloudc = true; System.Diagnostics.Process.Start("ConsoleApplication4.exe"); } if (myMouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && dayrec.Contains(myMouse.X, myMouse.Y)) { if (skyline == true) { if (butpcount == 0) { backdraw = Content.Load<Texture2D>("daySkyline1"); nightbut = Content.Load<Texture2D>("moonbtn"); daybut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount++; } } if (castle == true) { if (butpcount == 0) { backdraw = Content.Load<Texture2D>("dayCastle1"); nightbut = Content.Load<Texture2D>("moonbtn"); daybut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount++; } } if (mountain == true) { if (butpcount == 0) { backdraw = Content.Load<Texture2D>("dayMountain"); nightbut = Content.Load<Texture2D>("moonbtn"); daybut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount++; } } } if (myMouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && nightrec.Contains(myMouse.X, myMouse.Y)) { if (skyline == true) { if (butpcount == 1) { backdraw = Content.Load<Texture2D>("nightSkyline"); daybut = Content.Load<Texture2D>("sunbtn"); nightbut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount = 0; } } if (castle == true) { if (butpcount == 1) { backdraw = Content.Load<Texture2D>("nightCastle"); daybut = Content.Load<Texture2D>("sunbtn"); nightbut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount = 0; } } if (mountain == true) { if (butpcount == 1) { backdraw = Content.Load<Texture2D>("nightMountain"); daybut = Content.Load<Texture2D>("sunbtn"); nightbut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount = 0; } } } /* if (state.IsKeyDown(Keys.Enter))//if enter is pressed { gameState = GameState.Game;//gamestate equals game soundEffectInstance.Play(); }*/ } else if (gameState == GameState.Game) { if (startweb == true) { if (isstarted == false) { if (webcloudc == true) { new WebScrap(); // new WebScrap(); //new fileanalyer FA takes in input from webOutput.txt filename = "webOutput.txt"; } else { using (StreamReader read = new StreamReader("textname.txt")) { filename = read.ReadLine(); } } FileAnalyser FA = new FileAnalyser(filename); //Dictionary words gets dictionary from the FileAnalyser Words = FA.getDictionary(); //new ints rows and cols set to 0 and 100 respectivly int rows = 0; int cols = 100; //wordlimit setting how many words can be on the screen int wordlimit = 15; //wordlimitcurrent used to check if you have reach word limit int wordlimitcurrent = 0; //foreach used to go through words dictionary foreach (var word in Words) { //if you reach the wordlimit the dictionary will stop reading in words if (wordlimit <= wordlimitcurrent) { break; } //rec name is equal to word.key which is the current word String recName = word.Key; //myfont loaded as MyFont.spritefont from the content of the project SpriteFont myfont = Content.Load<SpriteFont>("MyFont"); //mycolor is a color which will be used to color the text Color mycolor = Color.Black; //adds to the font dictionary a new value with the current word and myfont FontDictionary.Add(word.Key, myfont); //adds to the color dictionary a new value with the current word and mycolor ColorsDictionary.Add(word.Key, mycolor); SpriteDictionary.Add(word.Key, wordcloud); //Vector2 called StringSize initialized with x and y of 30 and 20 Vector2 StringSize = new Vector2(30, 20); //foreach used to work through font dictionary foreach (var font in FontDictionary) { //each font with the font key the same as the word key is mesured and put into stringsize StringSize = font.Value.MeasureString(recName); } //if there is nothing in the rectangle dictionary is 0 if (RectangleDictionary.Count == 0) { //add to the rectangle dictionary with a recname as key an new rectangle with x and y of half width and height of screen //and height and width of the Stringsize RectangleDictionary.Add(recName, new Rectangle(this.GraphicsDevice.Viewport.Height / 2, this.GraphicsDevice.Viewport.Width / 2, (int)StringSize.X, (int)StringSize.Y)); } //if rectangles are already in dictionary else { //add to the rectangle dictionary with a recname as key an new rectangle with x and y of cols and rows //and height and width of the Stringsize RectangleDictionary.Add(recName, new Rectangle(cols, rows, (int)StringSize.X, (int)StringSize.Y)); } if (RectangleDictionary.Count == 10) { cols += (int)StringSize.X + 100; rows = 0; } if (RectangleDictionary.Count == 20) { cols += (int)StringSize.X + 100; rows = 0; } if (RectangleDictionary.Count == 30) { cols += (int)StringSize.X + 100; rows = 0; } rows += (int)StringSize.Y + 10; //wordlimitcurrent adds one to itself every time it loops wordlimitcurrent++; } biggestword = biggestWord(); } isstarted = true; } // soundEffectInstance.Play(); if (myMouse.LeftButton == ButtonState.Pressed && homerec.Contains(myMouse.X, myMouse.Y)) { gameState = GameState.Menu; startweb = false; FontDictionary.Clear(); RectangleDictionary.Clear(); Words.Clear(); ColorsDictionary.Clear(); SpriteDictionary.Clear(); isstarted = false; soundEffectInstance.Stop(); } if (myMouse.LeftButton == ButtonState.Pressed && umanrec.Contains(myMouse.X, myMouse.Y)) { gameState = GameState.Userman; soundEffectInstance.Stop(); currentgamestate = GameState.Game; } if (myMouse.LeftButton == ButtonState.Pressed && muterec.Contains(myMouse.X, myMouse.Y)) { if (musicbutpcount == 0) { soundEffectInstance.Resume(); musicbut = Content.Load<Texture2D>("music"); mutebut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); musicbutpcount++; } } if (myMouse.LeftButton == ButtonState.Pressed && musicrec.Contains(myMouse.X, myMouse.Y)) { if (musicbutpcount == 1) { soundEffectInstance.Pause(); musicbut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); mutebut = Content.Load<Texture2D>("mute"); musicbutpcount = 0; } } if (myMouse.LeftButton == ButtonState.Pressed && dayrec.Contains(myMouse.X, myMouse.Y)) { if (skyline == true) { if (butpcount == 0) { backdraw = Content.Load<Texture2D>("daySkyline1"); nightbut = Content.Load<Texture2D>("moonbtn"); daybut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount++; } } if (castle == true) { if (butpcount == 0) { backdraw = Content.Load<Texture2D>("dayCastle1"); nightbut = Content.Load<Texture2D>("moonbtn"); daybut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount++; } } if (mountain == true) { if (butpcount == 0) { backdraw = Content.Load<Texture2D>("dayMountain"); nightbut = Content.Load<Texture2D>("moonbtn"); daybut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount++; } } } if (myMouse.LeftButton == ButtonState.Pressed && nightrec.Contains(myMouse.X, myMouse.Y)) { if (skyline == true) { if (butpcount == 1) { backdraw = Content.Load<Texture2D>("nightSkyline"); daybut = Content.Load<Texture2D>("sunbtn"); nightbut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount = 0; } } if (castle == true) { if (butpcount == 1) { backdraw = Content.Load<Texture2D>("nightCastle"); daybut = Content.Load<Texture2D>("sunbtn"); nightbut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount = 0; } } if (mountain == true) { if (butpcount == 1) { backdraw = Content.Load<Texture2D>("nightMountain"); daybut = Content.Load<Texture2D>("sunbtn"); nightbut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); WordCountCol = Color.White; butpcount = 0; } } } //foreach used to go through rectangle dictionary foreach (var rec in RectangleDictionary) { //if right mouse button is pressed and mouse is in rectangle if (myMouse.RightButton == ButtonState.Pressed && rec.Value.Contains(myMouse.X, myMouse.Y)) { //new menuitem for showing count of words with string show word count foreach (var words in Words) { if (rec.Key == words.Key) { menuCountstr = "Word Count:" + words.Value.ToString(); } } Vector2 menuCountsiz = menufont.MeasureString(menuCountstr); menuCount = new Rectangle(myMouse.X, myMouse.Y, (int)menuCountsiz.X, (int)menuCountsiz.Y); //new menuitem for color change with string Change color menuColorstr = "Change Color"; Vector2 menuColorsiz = menufont.MeasureString(menuColorstr); menuColor = new Rectangle(myMouse.X, myMouse.Y + (int)menuCountsiz.Y, (int)menuColorsiz.X, (int)menuColorsiz.Y); //new menuitem for font change with string Change Remove menuFontstr = "Remove Word"; Vector2 menuFontsiz = menufont.MeasureString(menuFontstr); menuFont = new Rectangle(myMouse.X, myMouse.Y + (int)menuCountsiz.Y + (int)menuColorsiz.Y, (int)menuFontsiz.X, (int)menuFontsiz.Y); } if (myMouse.LeftButton == ButtonState.Pressed && menuCount.Contains(myMouse.X, myMouse.Y)) { if (rec.Value.Contains(menuCount.X, menuCount.Y)) { foreach (var words in Words) { //if the current rectangle equal the current word if (rec.Key == words.Key) { removestuff(); //write how many times the word in that rectangle appears WordCountstr = rec.Key + " appears " + words.Value.ToString() + " times"; } } } } //if the menuitem color change is pressed if (myMouse.LeftButton == ButtonState.Pressed && menuColor.Contains(myMouse.X, myMouse.Y)) { //checks rectangle contains menu and countcol == 0 if (rec.Value.Contains(menuCount.X, menuCount.Y) && countcol == 0) { //method remove stuff this.removestuff(); //color of word set to white ColorsDictionary[rec.Key] = Color.Black; //countcol incremented by one countcol++; } //checks rectangle contains menu and countcol == 1 if (rec.Value.Contains(menuCount.X, menuCount.Y) && countcol == 1) { this.removestuff(); //color of word set to red ColorsDictionary[rec.Key] = Color.Red; countcol++; } //checks rectangle contains menu and countcol == 2 if (rec.Value.Contains(menuCount.X, menuCount.Y) && countcol == 2) { this.removestuff(); //color of word set to green ColorsDictionary[rec.Key] = Color.Green; countcol++; } //checks rectangle contains menu and countcol == 3 if (rec.Value.Contains(menuCount.X, menuCount.Y) && countcol == 3) { this.removestuff(); //color of word set to blue ColorsDictionary[rec.Key] = Color.Blue; countcol = 0; } } //if the menuitem font change is pressed if (myMouse.LeftButton == ButtonState.Pressed && menuFont.Contains(myMouse.X, myMouse.Y)) { if (rec.Value.Contains(menuCount.X, menuCount.Y)) { this.removestuff(); //removes word RectangleDictionary.Remove(rec.Key); break; } } //if anywhere on the screen is pressed which is not a box and not the menu if (myMouse.LeftButton == ButtonState.Pressed && rec.Value.Contains(myMouse.X, myMouse.Y) == false && menuColor.Contains(myMouse.X, myMouse.Y) == false && menuCount.Contains(myMouse.X, myMouse.Y) == false && menuFont.Contains(myMouse.X, myMouse.Y) == false && menuRemove.Contains(myMouse.X, myMouse.Y) == false) { //remove stuff method this.removestuff(); } } } else if (gameState == GameState.Userman) { if (myMouse.LeftButton == ButtonState.Pressed && backrec.Contains(myMouse.X, myMouse.Y)) { gameState = currentgamestate; } } base.Update(gameTime); }
protected override void LoadContent() { //new randon rnd Random rnd = new Random(); //rnum set to random number between 0 and 15 rnum = rnd.Next(0, 15); //menufont loaded as Menufont.spritefont from the content of the project menufont = Content.Load<SpriteFont>("MenuFont"); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //mytexture is equal to new new texture2d of width and height of 1 myTexture = new Texture2D(GraphicsDevice, 1, 1); //set color of mytexture myTexture.SetData(new Color[] { Color.White }); //gets url you pass in // new WebScrap("http://en.wikipedia.org/wiki/Ireland"); //new fileanalyer FA takes in input from webOutput.txt FileAnalyser FA = new FileAnalyser("webOutput.txt"); //Dictionary words gets dictionary from the FileAnalyser Words = FA.getDictionary(); //new ints rows and cols set to 0 and 100 respectivly int rows = 0; int cols = 100; //wordlimit setting how many words can be on the screen int wordlimit = 15; int ranback = rnd.Next(1, 4); //wordlimitcurrent used to check if you have reach word limit int wordlimitcurrent = 0; if (ranback == 3) { backdraw = Content.Load<Texture2D>("dayCastle1"); castle = true; } else if (ranback == 2) { backdraw = Content.Load<Texture2D>("dayMountain"); mountain = true; } else if (ranback == 1) { backdraw = Content.Load<Texture2D>("daySkyline1"); skyline = true; } cloudone = Content.Load<Texture2D>("cloud"); cloudtwo = Content.Load<Texture2D>("CLOUD2"); cloudthree = Content.Load<Texture2D>("cloud"); filecloud = Content.Load<Texture2D>("fileCloud"); filecloudclick = Content.Load<Texture2D>("fileCloudClick"); webcloud = Content.Load<Texture2D>("urlCloud"); webcloudclick = Content.Load<Texture2D>("urlCloudClick"); nightbut = Content.Load<Texture2D>("moonbtn"); generatecloud = Content.Load<Texture2D>("generate"); title = Content.Load<Texture2D>("heading"); barcloud = Content.Load<Texture2D>("bar"); daybut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); dayrec = new Rectangle(750, 390, nightbut.Bounds.Height, nightbut.Bounds.Width); nightrec = new Rectangle(750, 430, nightbut.Bounds.Height, nightbut.Bounds.Width); filerec = new Rectangle(20, 170, filecloud.Bounds.Height, filecloud.Bounds.Width); webrec = new Rectangle(430, 190, webcloud.Bounds.Width, webcloud.Bounds.Height); webgenrec = new Rectangle(500, 390, generatecloud.Bounds.Height, generatecloud.Bounds.Width); filegenrec = new Rectangle(390, 390, generatecloud.Bounds.Height, generatecloud.Bounds.Width); WordCountCol = Color.White; uman = Content.Load<Texture2D>("help"); umanrec = new Rectangle(500, 430, uman.Bounds.Height, uman.Bounds.Width); backbut = Content.Load<Texture2D>("back"); backrec = new Rectangle(10, 430, backbut.Bounds.Height, backbut.Bounds.Width); ssbut = Content.Load<Texture2D>("cam"); ssrec = new Rectangle(700, 430, ssbut.Bounds.Height, ssbut.Bounds.Width); homebut = Content.Load<Texture2D>("home"); homerec = new Rectangle(550, 430, homebut.Bounds.Height, homebut.Bounds.Width); musicbut = Content.Load<Texture2D>("Music"); musicrec = new Rectangle(600, 430, musicbut.Bounds.Height, musicbut.Bounds.Width); mutebut = new Texture2D(GraphicsDevice, 5, 5, false, SurfaceFormat.Color); muterec = new Rectangle(650, 430, musicbut.Bounds.Height, musicbut.Bounds.Width); wordcloud = Content.Load<Texture2D>("wordCloud"); //foreach used to go through words dictionary foreach (var word in Words) { //if you reach the wordlimit the dictionary will stop reading in words if (wordlimit <= wordlimitcurrent) { break; } //rec name is equal to word.key which is the current word String recName = word.Key; //myfont loaded as MyFont.spritefont from the content of the project SpriteFont myfont = Content.Load<SpriteFont>("MyFont"); //mycolor is a color which will be used to color the text Color mycolor = Color.Black; //adds to the font dictionary a new value with the current word and myfont FontDictionary.Add(word.Key, myfont); //adds to the color dictionary a new value with the current word and mycolor ColorsDictionary.Add(word.Key, mycolor); SpriteDictionary.Add(word.Key, wordcloud); //Vector2 called StringSize initialized with x and y of 30 and 20 Vector2 StringSize = new Vector2(30, 20); //foreach used to work through font dictionary foreach (var font in FontDictionary) { //each font with the font key the same as the word key is mesured and put into stringsize StringSize = font.Value.MeasureString(recName); } //if there is nothing in the rectangle dictionary is 0 if (RectangleDictionary.Count == 0) { //add to the rectangle dictionary with a recname as key an new rectangle with x and y of half width and height of screen //and height and width of the Stringsize RectangleDictionary.Add(recName, new Rectangle(this.GraphicsDevice.Viewport.Height / 2, this.GraphicsDevice.Viewport.Width / 2, (int)StringSize.X, (int)StringSize.Y)); } //if rectangles are already in dictionary else { //add to the rectangle dictionary with a recname as key an new rectangle with x and y of cols and rows //and height and width of the Stringsize RectangleDictionary.Add(recName, new Rectangle(cols, rows, (int)StringSize.X, (int)StringSize.Y)); } if (RectangleDictionary.Count == 10) { cols += (int)StringSize.X + 100; rows = 0; } if (RectangleDictionary.Count == 20) { cols += (int)StringSize.X + 100; rows = 0; } if (RectangleDictionary.Count == 30) { cols += (int)StringSize.X + 100; rows = 0; } rows += (int)StringSize.Y + 10; //wordlimitcurrent adds one to itself every time it loops wordlimitcurrent++; } }