/// <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); background = new graphics2d(Content, "fullmoon", displaywidth, displayheight); gameoverimage = new graphics2d(Content, "gameover", displaywidth, displayheight); for (int i = 0; i < numberofballs; i++) { float tempsize = (float)(randomiser.Next(100) + 1) * ballsizeratio; if (tempsize < miniballsize) { tempsize = miniballsize; } balls[i] = new sprites2d(Content, "ast1", displaywidth / 2, displayheight / 2, tempsize, new Color((byte)randomiser.Next(255), (byte)randomiser.Next(255), (byte)randomiser.Next(255)), true, randomiser); } collidesound = Content.Load <SoundEffect>("rocks"); soundtrack1 = Content.Load <SoundEffect>("explosive_attack"); music1 = soundtrack1.CreateInstance(); music1.IsLooped = true; music1.Volume = 0.5f; soundtrack2 = Content.Load <SoundEffect>("iron-man"); music2 = soundtrack2.CreateInstance(); music2.IsLooped = true; music2.Volume = 0.5f; mainfont = Content.Load <SpriteFont>("quartz4"); reset(); }
/// <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); backgscroll = new scrollingbackground(Content, "space", 1, 5, 5); gameoverimage = new graphics2d(Content, "gameover", displaywidth, displayheight); for (int i = 0; i < numberofballs; i++) { float tempsize = (float)(randomiser.Next(100) + 1) * ballsizeratio; if (tempsize < miniballsize) { tempsize = miniballsize; } balls[i] = new sprites2d(Content, "ast1", displaywidth / 2, displayheight / 2, tempsize, new Color((byte)randomiser.Next(255), (byte)randomiser.Next(255), (byte)randomiser.Next(255)), true, randomiser); } collidesound = Content.Load <SoundEffect>("rocks"); soundtrack1 = Content.Load <SoundEffect>("explosive_attack"); music1 = soundtrack1.CreateInstance(); music1.IsLooped = true; music1.Volume = 0.5f; soundtrack2 = Content.Load <SoundEffect>("iron-man"); music2 = soundtrack2.CreateInstance(); music2.IsLooped = true; music2.Volume = 0.5f; mainfont = Content.Load <SpriteFont>("quartz4"); for (int i = 0; i < numberofballs; i++) { explosion[i] = new animation(Content, "effect_005", 0, 0, 1f, Color.White, false, 24, 4, 5, false); } shiphit[0] = new animation(Content, "effect_003", 0, 0, 1, Color.White, false, 24, 5, 5, false); shiphit[1] = new animation(Content, "effect_002", 0, 0, 1, Color.White, false, 24, 4, 5, false); bullet[0] = new ammo(Content, "bullet1", 0, 0, .1f, Color.White, false); bullet[1] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false); for (int b = 0; b < numberofbullets; b++) { for (int s = 0; s < numberofships; s++) { bullets5[s, b] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false); } } reset(); }
void loadsprites(ref sprites2d sprites, string spritename, int x, int y, float msize) //Void To Load Sprites { sprites.image = Content.Load <Texture2D>(spritename); sprites.position = new Vector3((float)x, (float)y, 0); sprites.size = msize; sprites.rect.Width = (int)(sprites.image.Width * msize); sprites.rect.Height = (int)(sprites.image.Height * msize); sprites.rect.Y = y; sprites.rect.X = x; sprites.origin.X = sprites.image.Width / 2; sprites.origin.Y = sprites.image.Height / 2; sprites.bsphere = new BoundingSphere(sprites.position, sprites.image.Width / 2); sprites.bbox = new BoundingBox(new Vector3(sprites.position.X - sprites.rect.Width / 2, sprites.position.Y - sprites.rect.Height / 2, 0), new Vector3(sprites.position.X + sprites.rect.Width / 2, sprites.position.Y + sprites.rect.Height / 2, 0)); }
/// <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); if (File.Exists(@"highscore.txt")) { String line; StreamReader sr = new StreamReader(@"highscore.txt"); line = sr.ReadLine(); line = line.Trim(); for (int i = 0; i < numberofhighscores & !sr.EndOfStream; i++) { highscores[i] = Convert.ToInt32(line); } sr.Close(); } background = new graphics2d(Content, "Background for Menus", displaywidth, displayheight); mousepointer1 = new sprites2d(Content, "X-Games-Cursor", 0, 0, 0.15f, Color.White, true, randomiser); mousepointer2 = new sprites2d(Content, "X-Games-Cursor-Highlight", 0, 0, 0.15f, Color.White, true, randomiser); menuoptions[0, 0] = new sprites2d(Content, "Start-Normal", displaywidth / 2, 200, 1, Color.White, true, randomiser); menuoptions[0, 1] = new sprites2d(Content, "Start-Selected", displaywidth / 2, 200, 1, Color.White, true, randomiser); menuoptions[1, 0] = new sprites2d(Content, "Options-Normal", displaywidth / 2, 300, 1, Color.White, true, randomiser); menuoptions[1, 1] = new sprites2d(Content, "options-Selected", displaywidth / 2, 300, 1, Color.White, true, randomiser); menuoptions[2, 0] = new sprites2d(Content, "High-Score-Normal", displaywidth / 2, 400, 1, Color.White, true, randomiser); menuoptions[2, 1] = new sprites2d(Content, "High-Score-Selected", displaywidth / 2, 400, 1, Color.White, true, randomiser); menuoptions[3, 0] = new sprites2d(Content, "Exit-Normal", displaywidth / 2, 500, 1, Color.White, true, randomiser); menuoptions[3, 1] = new sprites2d(Content, "Exit-Selected", displaywidth / 2, 500, 1, Color.White, true, randomiser); for (int i = 0; i < numberofoptions; i++) { menuoptions[i, 0].updateobject(); } mainfont = Content.Load <SpriteFont>("mainfont"); }
void loadbackgrounds(ref sprites2d bsprites, string sname, int x, int y, float bsize) // creats a void for loading bcckgrounds { bsprites.image = Content.Load<Texture2D>(sname); // loads the structures textures into the texture sname bsprites.position = new Vector3((float)x, (float)y, 0); bsprites.size = bsize; // loads the size varible into to bsize bsprites.rect.Y = y; bsprites.rect.X = x; bsprites.rect.Width = displaywidth; // sets the size of the image to the size of the displaywidth bsprites.rect.Height = displayheight; // sets the size of the image to the size of the displayheight bsprites.origin.Y = bsprites.image.Height / 2; // sets the Y origin to half the size of images height bsprites.origin.X = bsprites.image.Width / 2; // sets the X origin to half the size of images width }
void loadsprites(ref sprites2d sprite, string spritename, int x, int y, float msize) // creats void to for loading the smaller images { sprite.image = Content.Load<Texture2D>(spritename); sprite.position = new Vector3((float)x, (float)y, 0); sprite.size = msize; sprite.rect.Y = y; sprite.rect.X = x; sprite.rect.Width = (int)(sprite.image.Width * msize); sprite.rect.Height = (int)(sprite.image.Height * msize); sprite.origin.Y = sprite.image.Height / 2; sprite.origin.X = sprite.image.Width / 2; }
/// <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); background = new graphics2d(Content, "fullmoon", displaywidth, displayheight); gameoverimage = new graphics2d(Content, "gameover", displaywidth, displayheight); football = new sprites2d(Content, "football2", displaywidth / 2, displayheight / 2, 0.2f, Color.Tomato, true); mainfont = Content.Load<SpriteFont>("quartz4"); reset(); }
//Void To Load Sprites void loadsprites(ref sprites2d sprites, string spritename, int x, int y, float msize) { sprites.image = Content.Load<Texture2D>(spritename); sprites.position = new Vector3((float)x, (float)y, 0); sprites.size = msize; sprites.rect.Width = (int)(sprites.image.Width * msize); sprites.rect.Height = (int)(sprites.image.Height * msize); sprites.rect.Y = y; sprites.rect.X = x; sprites.origin.X = sprites.image.Width / 2; sprites.origin.Y = sprites.image.Height / 2; sprites.bsphere = new BoundingSphere(sprites.position, sprites.image.Width / 2); sprites.bbox = new BoundingBox(new Vector3(sprites.position.X - sprites.rect.Width / 2, sprites.position.Y - sprites.rect.Height / 2, 0), new Vector3(sprites.position.X + sprites.rect.Width / 2, sprites.position.Y + sprites.rect.Height / 2, 0)); }