/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Load in high scores if (File.Exists(@"highscore.txt")) // This checks to see if the file exists { StreamReader sr = new StreamReader(@"highscore.txt"); // Open the file String line; // Create a string variable to read each line into for (int i = 0; i < numberofhighscores && !sr.EndOfStream; i++) { line = sr.ReadLine(); // Read the first line in the text file highscorename[i] = line.Trim(); // Read high score name if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file line = line.Trim(); // This trims spaces from either side of the text highscore[i] = (int)Convert.ToDecimal(line); // This converts line to numeric } } sr.Close(); // Close the file } Array.Sort(highscore, highscorename); Array.Reverse(highscore); Array.Reverse(highscorename); background = new graphic2d(Content, "backgroundformenus", displaywidth, displayheight); mousepointer1 = new sprite2d(Content, "X-Games-Cursor", 0, 0, 0.15f, Color.White, true); mousepointer2 = new sprite2d(Content, "X-Games-Cursor-Highlight", 0, 0, 0.15f, Color.White, true); menuoptions[0, 0] = new sprite2d(Content, "1", displaywidth / 2, 100, 0.7f, Color.White, true); menuoptions[0, 1] = new sprite2d(Content, "2", displaywidth / 2, 100, .7f, Color.White, true); menuoptions[1, 0] = new sprite2d(Content, "3", displaywidth / 2, 200, .7f, Color.White, true); menuoptions[1, 1] = new sprite2d(Content, "4", displaywidth / 2, 200, .7f, Color.White, true); menuoptions[2, 0] = new sprite2d(Content, "5", displaywidth / 2, 300, .7f, Color.White, true); menuoptions[2, 1] = new sprite2d(Content, "6", displaywidth / 2, 300, .7f, Color.White, true); menuoptions[3, 0] = new sprite2d(Content, "7", displaywidth / 2, 400, 0.7f, Color.White, true); menuoptions[3, 1] = new sprite2d(Content, "8", displaywidth / 2, 400, 0.7f, Color.White, true); for (int i = 0; i < numberofoptions; i++) menuoptions[i, 0].updateobject(); mainfont = Content.Load<SpriteFont>("mainfont"); //mainfont = Content.Load<SpriteFont>("quartz4"); gameoverimage = new graphic2d(Content, "gameover", displaywidth, displayheight); gameoverimage.stretch2fit(displaywidth, displayheight); playerdeath = Content.Load<SoundEffect>("GLASS02"); playerdeath2 = Content.Load<SoundEffect>("CRASH03"); winner = new graphic2d(Content, "winner", displaywidth, displayheight); gamemusic = Content.Load<SoundEffect>("iron-man"); music = gamemusic.CreateInstance(); //resetgame(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Load in high scores if (File.Exists(@"highscore.txt")) // This checks to see if the file exists { StreamReader sr = new StreamReader(@"highscore.txt"); // Open the file String line; // Create a string variable to read each line into for (int i = 0; i < numberofhighscores && !sr.EndOfStream; i++) { line = sr.ReadLine(); // Read the first line in the text file highscorename[i] = line.Trim(); // Read high score name if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file line = line.Trim(); // This trims spaces from either side of the text highscore[i] = (int)Convert.ToDecimal(line); // This converts line to numeric } } sr.Close(); // Close the file } // sorts highscores and high score names Array.Sort(highscore, highscorename); Array.Reverse(highscore); Array.Reverse(highscorename); background = new graphic2d(Content, "backgroundformenus", displaywidth, displayheight);// load in graphic mousepointer1 = new sprite2d(Content, "X-Games-Cursor", 0, 0, 0.15f, Color.White, true);// loads in sprites mousepointer2 = new sprite2d(Content, "X-Games-Cursor-Highlight", 0, 0, 0.15f, Color.White, true); menuoptions[0, 0] = new sprite2d(Content, "1", displaywidth / 2, 75, 0.7f, Color.White, true); menuoptions[0, 1] = new sprite2d(Content, "2", displaywidth / 2, 75, .7f, Color.White, true); menuoptions[1, 0] = new sprite2d(Content, "5", displaywidth / 2, 232, .7f, Color.White, true); menuoptions[1, 1] = new sprite2d(Content, "6", displaywidth / 2, 232, .7f, Color.White, true); menuoptions[2, 0] = new sprite2d(Content, "7", displaywidth / 2, 388, 0.7f, Color.White, true); menuoptions[2, 1] = new sprite2d(Content, "8", displaywidth / 2, 388, 0.7f, Color.White, true); for (int i = 0; i < numberofoptions; i++)// update menu options menuoptions[i, 0].updateobject(); mainfont = Content.Load<SpriteFont>("mainfont"); //mainfont = Content.Load<SpriteFont>("quartz4"); gameoverimage = new graphic2d(Content, "gameover", displaywidth, displayheight); gameoverimage.stretch2fit(displaywidth, displayheight); playerdeath = Content.Load<SoundEffect>("GLASS02"); playerdeath2 = Content.Load<SoundEffect>("CRASH03"); winner = new graphic2d(Content, "winner", displaywidth, displayheight); gamemusic = Content.Load<SoundEffect>("iron-man"); music = gamemusic.CreateInstance(); megaman = new animatedsprite(new Vector3(50, 500, 0), 0.95f, 2f, 1f, 4);// loads animation megaman.spriteanimation[0] = new animation(Content, "megamanx", 100, 100, 2f, Color.White, true, 13, 1, 11, true, false, false);// animatesa animation megaman.spriteanimation[1] = new animation(Content, "megamanx", 100, 100, 2f, Color.White, true, 13, 1, 11, true, false, true); megaman.spriteanimation[2] = new animation(Content, "megamanjump", 100, 100, 2f, Color.White, true, 14, 1, 7, false, false, false); megaman.spriteanimation[3] = new animation(Content, "megamanjump", 100, 100, 2f, Color.White, true, 14, 1, 7, false, false, true); for (int i = 0; i < numofsuperballs; i++) { superballs[i] = new animatedsprite(new Vector3(100, displayheight - 25, 0), 0.95f, 2f, 0.5f, 1);// loads animation superballs[i].spriteanimation[0] = new animation(Content, "cast_006", 0, 0, 0.3f, Color.White, true, 18, 4, 5, true, false, false);// animatesa animation superballs[i].state = 0; superballs[i].gravity = 0; } //resetgame(); }