/// <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); // TODO: use this.Content to load your game content here mainfont = Content.Load<SpriteFont>("quartz4"); // Load font background = new graphic2d(Content, "Background for Menus", 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, "Start-Normal", displaywidth / 2, 200, 1, Color.White, true); menuoptions[0, 1] = new sprite2d(Content, "Start-Selected", displaywidth / 2, 200, 1, Color.White, true); menuoptions[1, 0] = new sprite2d(Content, "Options-Normal", displaywidth / 2, 300, 1, Color.White, true); menuoptions[1, 1] = new sprite2d(Content, "Options-Selected", displaywidth / 2, 300, 1, Color.White, true); menuoptions[2, 0] = new sprite2d(Content, "High-Score-Normal", displaywidth / 2, 400, 1, Color.White, true); menuoptions[2, 1] = new sprite2d(Content, "High-Score-Selected", displaywidth / 2, 400, 1, Color.White, true); menuoptions[3, 0] = new sprite2d(Content, "Exit-Normal", displaywidth / 2, 500, 1, Color.White, true); menuoptions[3, 1] = new sprite2d(Content, "Exit-Selected", displaywidth / 2, 500, 1, Color.White, true); for (int i = 0; i < numberofoptions; i++) { menuoptions[i, 0].updateobject(); } // 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 highscorenames[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 highscores[i] = (int)Convert.ToDecimal(line); // This converts line to numeric } } sr.Close(); // Close the file } }
/// <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); // TODO: use this.Content to load your game content here mainfont = Content.Load<SpriteFont>("quartz4"); // Load the quartz4 font background = new graphic2d(Content, "Background for Menus", displaywidth, displayheight); up = new sprite2d(Content, "up", 105, displayheight - 180, 0.3f, Color.White, true); down = new sprite2d(Content, "down",105, displayheight - 50, 0.3f, Color.White, true); left = new sprite2d(Content, "left", 50, displayheight - 115, 0.3f, Color.White, true); right = new sprite2d(Content, "right", 160, displayheight - 115, 0.3f, Color.White, true); left2 = new sprite2d(Content, "left", displaywidth-180, displayheight - 100, 0.3f, Color.White, true); right2 = new sprite2d(Content, "right", displaywidth-60, displayheight - 100, 0.3f, Color.White, true); menuoptions[0] = new sprite2d(Content, "player1", displaywidth / 2, 150, 1, Color.White, true); menuoptions[1] = new sprite2d(Content, "options", displaywidth / 2, 220, 1, Color.White, true); menuoptions[2] = new sprite2d(Content, "highscore", displaywidth / 2, 290, 1, Color.White, true); menuoptions[3] = new sprite2d(Content, "exit", displaywidth / 2, 360, 1, Color.White, true); // Load the 3D models for the static objects in the game from the ContentManager ground = new staticmesh(Content, "sground", 100f, new Vector3(0, -40, 0), new Vector3(0, 0, 0)); // Initialise robot1 object uservehicle = new model3d(Content, "tiefighter", 2f, new Vector3(1000, 0, 1000), new Vector3(0, 0, 0), 0.002f, 0.06f, 10); /* tree[50] = new staticmesh(Content, "tank", (float)(randomiser.Next(20) + 1) / 10, new Vector3(randomiser.Next(6000) - 3000, 200, randomiser.Next(6000) - 3000), new Vector3(0, randomiser.Next(7), 0)); tree[51] = new staticmesh(Content, "ship", (float)(randomiser.Next(20) + 1) / 10, new Vector3(randomiser.Next(6000) - 3000, 200, randomiser.Next(6000) - 3000), new Vector3(0, randomiser.Next(7), 0)); tree[52] = new staticmesh(Content, "stars", 10, new Vector3(randomiser.Next(6000) - 3000, 200, randomiser.Next(6000) - 3000), new Vector3(0, randomiser.Next(7), 0)); */ // Load High Scores in using (IsolatedStorageFile savegamestorage = IsolatedStorageFile.GetUserStoreForApplication()) { if (savegamestorage.FileExists("highscores.txt")) { using (IsolatedStorageFileStream fs = savegamestorage.OpenFile("highscores.txt", System.IO.FileMode.Open)) { using (StreamReader sr = new StreamReader(fs)) { string line; for (int i = 0; i < numberofhighscores; i++) { line = sr.ReadLine(); highscores[i] = Convert.ToInt32(line); } sr.Close(); } } } } // Sort high scores Array.Sort(highscores); Array.Reverse(highscores); }
/// <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); // TODO: use this.Content to load your game content here background = new graphic2d(Content, "Background for Menus", 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, "Start-Normal", displaywidth / 2, 100, 1, Color.White, true); menuoptions[0, 1] = new sprite2d(Content, "Start-Selected", displaywidth / 2, 100, 1, Color.White, true); menuoptions[1, 0] = new sprite2d(Content, "Options-Normal", displaywidth / 2, 200, 1, Color.White, true); menuoptions[1, 1] = new sprite2d(Content, "Options-Selected", displaywidth / 2, 200, 1, Color.White, true); menuoptions[2, 0] = new sprite2d(Content, "High-Score-Normal", displaywidth / 2, 300, 1, Color.White, true); menuoptions[2, 1] = new sprite2d(Content, "High-Score-Selected", displaywidth / 2, 300, 1, Color.White, true); menuoptions[3, 0] = new sprite2d(Content, "Exit-Normal", displaywidth / 2, 400, 1, Color.White, true); menuoptions[3, 1] = new sprite2d(Content, "Exit-Selected", displaywidth / 2, 400, 1, Color.White, true); for (int i = 0; i < numberofoptions; i++) { menuoptions[i, 0].updateobject(); } backgscroll = new scrollingbackground2(Content, "skypan", 4f, 6, 1); backgscroll.image[1, 0] = Content.Load<Texture2D>("skypan2"); // backgscroll.image[2, 0] = Content.Load<Texture2D>("skypan2"); // backgscroll.image[5, 0] = Content.Load<Texture2D>("skypan2"); backgscroll.makehorizontal(displayheight); mainfont = Content.Load<SpriteFont>("quartz4"); // Load font // Initialise game character, setting position, friction and gravity cutedude = new animatedsprite(new Vector3(50, 300, 0), 0.95f, 2f, 1f, 4); // cutedude.spriteanimation[0] = new animation(Content, "superguy1", 100, 100, 2f, Color.White, true, 6, 1, 4, true); // cutedude.spriteanimation[1] = new animation(Content, "superguy2", 100, 100, 2f, Color.White, true, 6, 1, 4, true); cutedude.spriteanimation[0] = new animation(Content, "cuteman", 100, 100, 0.8f, Color.White, true, 6, 1, 4, true,false); cutedude.spriteanimation[1] = new animation(Content, "cuteman2", 100, 100, 0.8f, Color.White, true, 6, 1, 4, true, true); cutedude.spriteanimation[2] = new animation(Content, "cutejump", 100, 100, 0.8f, Color.White, true, 14, 1, 7, false, false); cutedude.spriteanimation[3] = new animation(Content, "cutejump2", 100, 100, 0.8f, Color.White, true, 14, 1, 7, false,true); hitsound = Content.Load<SoundEffect>("ballhit"); // Values for sonic type game //cutedude = new animatedsprite(new Vector3(300, 300, 0), 0.995f, 1.5f, 2f); //cutedude.running = new animation(Content, "sonic", 100, 100, 1f, Color.White, true, 24, 1, 4); // cutedude = new animatedsprite(new Vector3(300, 300, 0), 0.95f, 1f); // cutedude.running = new animation(Content, "dragon", 100, 100, 1f, Color.White, true, 24, 4, 3); // Load the platforms and position them platform[0] = new sprite2d(Content, "BRICK_blue", 450, 350, 1, Color.White, true); for (int i = 1; i < numberofplatforms; i++) platform[i] = new sprite2d(Content, "BRICK_blue", 500 + (i * platform[0].rect.Width), 250, 1, Color.White, true); for (int i = 11; i < numberofplatforms; i++) platform[i] = new sprite2d(Content, "BRICK_blue", 500 + (i * platform[0].rect.Width), 350, 1, Color.White, true); platform[8] = new sprite2d(Content, "BRICK_green", (int)platform[8].position.X, (int)(platform[8].position.Y - 150), 1f, Color.White, true); platform[9] = new sprite2d(Content, "BRICK_green", (int)platform[9].position.X, (int)(platform[9].position.Y - 150), 1f, Color.White, true); platform[10] = new sprite2d(Content, "BRICK_green", (int)platform[16].position.X, (int)(platform[16].position.Y - platform[16].rect.Height), 1f, Color.White, true); platform[18] = new sprite2d(Content, "BRICK_green", 3100, 420, 3f, Color.White, true); platform[19] = new sprite2d(Content, "BRICK_green", 3500, 220, 1.5f, Color.White, true); for (int i = 20; i < numberofplatforms; i++) platform[i] = new sprite2d(Content, "BRICK_blue", (int)platform[19].bbox.Max.X + ((i-17) * platform[0].rect.Width), 250, 1, Color.White, true); // 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 highscorenames[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 highscores[i] = (int)Convert.ToDecimal(line); // This converts line to numeric } } sr.Close(); // Close the file } }
/// <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(); }
/// <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); // Create a music track soundtrack = Content.Load<SoundEffect>("Behind-every-Idea"); music = soundtrack.CreateInstance(); playergun = Content.Load<SoundEffect>("starting_pistol"); zombiehit = Content.Load<SoundEffect>("Zombie Attacked"); playerhit = Content.Load<SoundEffect>("Bite"); //Make the track looped and if its stop then play it music.IsLooped = true; music.Volume = 0.75f; if (music.State == SoundState.Playing) music.Stop(); // TODO: use this.Content to load your game content here mainfont = Content.Load<SpriteFont>("quartz4"); // Load the quartz4 font background = new graphic2d(Content, "ZombieBG", displaywidth, displayheight); background2 = new graphic2d(Content, "skyline", displaywidth, displayheight); backgroundGO = new graphic2d(Content, "gameoverbg", displaywidth, displayheight); up = new sprite2d(Content, "up", 115, displayheight - 150, 0.25f, Color.White, true); down = new sprite2d(Content, "down",115, displayheight - 50, 0.25f, Color.White, true); left = new sprite2d(Content, "left", 55, displayheight - 100, 0.25f, Color.White, true); right = new sprite2d(Content, "right", 175, displayheight - 100, 0.25f, Color.White, true); controlshowto = new sprite2d(Content, "Controls", 425, displayheight - 225, 0.65f, Color.White, true); firebut = new sprite2d(Content, "fire", 700, displayheight - 100, 0.50f, Color.White, true); menuback = new sprite2d(Content, "right", displaywidth - 50, 50, 0.25f, Color.White, true); menuoptions[0] = new sprite2d(Content, "buttonstart", displaywidth / 2, 150, 0.50f, Color.White, true); menuoptions[1] = new sprite2d(Content, "buttonhowtoplay", displaywidth / 2, 220, 0.50f, Color.White, true); menuoptions[2] = new sprite2d(Content, "buttonhighscore", displaywidth / 2, 290, 0.50f, Color.White, true); menuoptions[3] = new sprite2d(Content, "buttonexit", displaywidth / 2, 360, 0.50f, Color.White, true); // Initialise robot1 object playerchar = new model3d(Content, "player", 2f, new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.002f, 0.06f, 10); playerchar.bboxsize = new Vector3(25, 115, 25); // Load High Scores in using (IsolatedStorageFile savegamestorage = IsolatedStorageFile.GetUserStoreForApplication()) { if (savegamestorage.FileExists("highscores.txt")) { using (IsolatedStorageFileStream fs = savegamestorage.OpenFile("highscores.txt", System.IO.FileMode.Open)) { using (StreamReader sr = new StreamReader(fs)) { string line; for (int i = 0; i < numberofhighscores; i++) { line = sr.ReadLine(); highscores[i] = Convert.ToInt32(line); } sr.Close(); } } } } // Sort high scores Array.Sort(highscores); Array.Reverse(highscores); }
/// <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); mainfont = Content.Load<SpriteFont>("quartz4"); gameoverimage = new graphic2d(Content, "gameover", 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(); }