示例#1
0
        void resetlevel()
        {
            // Level 1
            if (levelon == 1)
            {
                megaman = new animatedsprite(new Vector3(50, 500, 0), 0.95f, 2f, 1f, 4);
                megaman.spriteanimation[0] = new animation(Content, "megamanx", 100, 100, 2f, Color.White, true, 13, 1, 11, true, false, false);
                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);

                backgscroll = new scrollingbackground(Content, "backgroundforscrolling", 4f, 3, 1);
                backgscroll.makehorizontal(displayheight);

                balls[0] = new sprite2d(Content, "ball", 340, displayheight - 50, 0.2f, Color.White, true);
                for (int i = 1; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, true);

                }

                balls[5] = new sprite2d(Content, "ball", 500 + (5 * 335), displayheight - 25, 0.2f, Color.White, true);
                balls[6] = new sprite2d(Content, "ball", 500 + (8 * 335), displayheight - 25, 0.2f, Color.White, true);

                for (int i = 7; i < numberofballs; i++)
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, false);

                for (int i = 7; i < numberofballs; i++)
                    balls[7].visible = false;

                platforms[0] = new sprite2d(Content, "red", 340, displayheight - 20, 1, Color.White, true);

                for (int i = 1; i < 5; i++)
                    platforms[i] = new sprite2d(Content, "red", 500 + (i * platforms[0].rect.Width) * 5, displayheight - 20, 1, Color.White, true);
                platforms[5] = new sprite2d(Content, "redflip", 339, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[6] = new sprite2d(Content, "redflip", 834, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[7] = new sprite2d(Content, "redflip", 839 + 330, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[8] = new sprite2d(Content, "redflip", 845 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[9] = new sprite2d(Content, "redflip", 849 + 330 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, true);

                platforms[10] = new sprite2d(Content, "red", 849 + 990 + 600, displayheight - platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[11] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight - 200, 1, Color.White, true);
                platforms[12] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight - 200, 1, Color.White, true);

                for (int i = 13; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight + 500 + 200, 1, Color.White, false);

                spikes[0] = new sprite2d(Content, "spikes", 100, 500, 1, Color.White, false);

                for (int i = 1; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", platforms[9].rect.X + 330, displayheight - spikes[0].rect.Height / 2, 1, Color.White, false);

                for (int i = 0; i < numberofballs; i++)
                {
                    do
                    {
                        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(20) + 1) / 2, 0);
                    } while (balls[i].velocity.Y == 0);
                }
                //for (int i = 0; i < numberofballs; i++)
                //{
                //    balls[i].velocity = new Vector3(0, -2, 0);
                //}
                for (int i = 5; i < numberofballs; i++)
                    balls[i].velocity = new Vector3(2, 0, 0);

                collectable = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);

                collectable2 = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);
                }
            }

            // Level 2
            if (levelon == 2)
            {
                backgscroll = new scrollingbackground(Content, "skypan2", 4f, 1, 1);
                backgscroll.makehorizontal(displayheight);

                megaman = new animatedsprite(new Vector3(50, 500, 0), 0.95f, 2f, 1f, 4);
                megaman.spriteanimation[0] = new animation(Content, "megamanx", 100, 100, 2f, Color.White, true, 13, 1, 11, true, false, false);
                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);

                balls[0] = new sprite2d(Content, "ball", 340, displayheight - 50, 0.2f, Color.White, true);
                for (int i = 0; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, false);

                }
                //balls[5] = new sprite2d(Content, "ball", 500 + (5 * 335), displayheight - 25, 0.2f, Color.White, false);
                //balls[6] = new sprite2d(Content, "ball", 500 + (8 * 335), displayheight - 25, 0.2f, Color.White, false);

                platforms[0] = new sprite2d(Content, "green", 340, displayheight - 20, 1, Color.White, true);

                for (int i = 1; i < 5; i++)
                    platforms[i] = new sprite2d(Content, "green", 500 + (i * platforms[0].rect.Width) * 5, displayheight - 20 - (i * 40), 1, Color.White, true);
                for (int i = 5; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "green", platforms[4].rect.X + 330 + (i * platforms[3].rect.Width), displayheight / 2, 1, Color.White, true);
                //platforms[6] = new sprite2d(Content, "greenflip", 834, platforms[0].rect.Height / 2, 1, Color.White, false);
                //platforms[7] = new sprite2d(Content, "greenflip", 839 + 330, platforms[0].rect.Height / 2, 1, Color.White, false);
                //platforms[8] = new sprite2d(Content, "greenflip", 845 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, false);
                //platforms[9] = new sprite2d(Content, "greenflip", 849 + 330 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, false);

                platforms[10] = new sprite2d(Content, "green", platforms[4].rect.X + 330, displayheight / 2, 1, Color.White, true);
                platforms[11] = new sprite2d(Content, "green", platforms[9].rect.X + 330, displayheight / 2, 1, Color.White, true);
                platforms[12] = new sprite2d(Content, "greenflip", platforms[9].rect.X + 330, displayheight - 400, 1, Color.White, true);

                for (int i = 13; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight + 500 + 200, 1, Color.White, false);

                collectable = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 0.1f, Color.White, true);

                collectable2 = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);

                for (int i = 0; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", platforms[9].rect.X + 330, displayheight - spikes[i].rect.Height / 2, 1, Color.White, true);

                animation powerup = new animation(Content, "cast_006", platforms[9].rect.X + 330, displayheight - 200, 0.1f, Color.White, true, 25, 6, 6);
                powerup.start(new Vector3(200, 300, 0));

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);
                }

                //for (int i = 0; i < numberofballs; i++)
                //{
                //    do
                //    {
                //        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(20) + 1) / 2, 0);
                //    } while (balls[i].velocity.Y == 0);
                //}
            }

            // Level 3
            if (levelon == 3)
            {
                backgscroll = new scrollingbackground(Content, "sky", 4f, 3, 1);
                backgscroll.makehorizontal(displayheight);

                megaman = new animatedsprite(new Vector3(50, 350, 0), 0.95f, 2f, 1f, 4);
                megaman.spriteanimation[0] = new animation(Content, "megamanx", 100, 100, 2f, Color.White, true, 13, 1, 11, true, false, false);
                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);

                balls[0] = new sprite2d(Content, "ball", 340, displayheight - 50, 0.2f, Color.White, false);
                for (int i = 1; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, false);

                }
                balls[5] = new sprite2d(Content, "ball", 500 + (5 * 335), displayheight - 25, 0.2f, Color.White, true);
                balls[6] = new sprite2d(Content, "ball", 500 + (8 * 335), displayheight - 25, 0.2f, Color.White, true);

                platforms[0] = new sprite2d(Content, "diamond", 50, displayheight - 100, 1, Color.White, true);
                for (int i = 1; i < 5; i++)
                    platforms[i] = new sprite2d(Content, "diamond", 80 + (i * platforms[0].rect.Width) * 4, displayheight - 100, 1, Color.White, true);

                for (int i = 5; i < 8; i++)
                    platforms[i] = new sprite2d(Content, "diamond", (i * platforms[0].rect.Width - 50) * 5, displayheight - 20 - (i * 40), 1, Color.White, true);

                platforms[10] = new sprite2d(Content, "diamond", (platforms[9].rect.X - 400), displayheight - 200, 1, Color.White, true);
                platforms[11] = new sprite2d(Content, "diamond", platforms[9].rect.X - 50, displayheight - 150, 1, Color.White, true);
                platforms[8] = new sprite2d(Content, "red", platforms[7].rect.X, displayheight - 75, 1, Color.White, true);
                platforms[9] = new sprite2d(Content, "diamond", platforms[7].rect.X + 60, displayheight - 120, 1, Color.White, true);
                platforms[12] = new sprite2d(Content, "diamond", platforms[9].rect.X + 1000, displayheight - 200, 1, Color.White, true);
                for (int i = 13; i < 17; i++)
                    platforms[i] = new sprite2d(Content, "triangle", i * platforms[9].rect.Width + 2700, displayheight - 300, 1, Color.White, true);

                platforms[20] = new sprite2d(Content, "diamond", platforms[19].rect.Width + 3400, displayheight - 100, 1, Color.White, true);

                for (int i = 21; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "triangle", 849 + 990 + 600, displayheight + 500 + 200, 1, Color.White, false);

                collectable = new sprite2d(Content, "car", platforms[9].rect.X + 100, 100, 0.1f, Color.White, true);
                collectable2 = new sprite2d(Content, "saucer2", 2255, 400, 0.1f, Color.White, true);

                spikes[0] = new sprite2d(Content, "spikes", 100, displayheight - 40, 1, Color.White, true);

                for (int i = 1; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", 100 + (i * spikes[0].rect.Width), displayheight - 40, 1, Color.White, true);

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, (i * 35), 1, Color.White, false);
                }

                for (int i = 0; i < numberofballs; i++)
                {
                    do
                    {
                        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(40) + 1) / 2f, 0);
                    } while (balls[i].velocity.Y == 0);
                }

            }
            if (levelon == 4)
            {
                backgscroll = new scrollingbackground(Content, "backgroundscrolling2", 4f, 5, 1);
                backgscroll.makehorizontal(displayheight);

                megaman = new animatedsprite(new Vector3(50, 500, 0), 0.95f, 2f, 1f, 4);
                megaman.spriteanimation[0] = new animation(Content, "megamanx", 100, 100, 2f, Color.White, true, 13, 1, 11, true, false, false);
                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 < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "red", (i * 70), displayheight + 100 + platforms[i].rect.Height / 2, 1, Color.White, false);
                for (int i = 56; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "redflip", platforms[0].rect.X + (10 * 1), 100 + platforms[i].rect.Height / 2, 1, Color.White, false);

                for (int i = 0; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", 100 + (i * spikes[0].rect.Width), displayheight + 340, 1, Color.White, false);

                //balls[0] = new sprite2d(Content, "ball", 50, displayheight - 50, 0.2f, Color.White, true);
                for (int i = 7; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 40 + (i * 120), displayheight - 50, 0.2f, Color.White, true);

                }

                balls[39] = new sprite2d(Content, "ball", 340, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, true);

                for (int i = 0; i < numberofballs; i++)
                {
                    do
                    {
                        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(40) + 1) / 2f, 0);
                    } while (balls[i].velocity.Y == 0);
                }
                balls[39].velocity = new Vector3(8, 0, 0);

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);
                }

                collectable = new sprite2d(Content, "car", 2980, 205, 0.1f, Color.White, true);

                collectable2 = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
            }
            if (levelon == 5)
            {
                backgscroll = new scrollingbackground(Content, "skypan2", 4f, 1, 1);
                backgscroll.makehorizontal(displayheight);

                megaman = new animatedsprite(new Vector3(50, 500, 0), 0.95f, 2f, 1f, 4);
                megaman.spriteanimation[0] = new animation(Content, "megamanx", 100, 100, 2f, Color.White, true, 13, 1, 11, true, false, false);
                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);

                platforms[0] = new sprite2d(Content, "orange", 200, 350, 1, Color.White, true);
                for (int i = 0; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "orange", (i * 700), 350, 1, Color.White, true);

                balls[37] = new sprite2d(Content, "ball", 540, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, true);

                balls[38] = new sprite2d(Content, "ball", 1500, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, true);
                balls[39] = new sprite2d(Content, "ball", 2500, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, true);

                for (int i = 0; i < numberofballs; i++)
                {
                    balls[i].visible = false;
                }
                balls[37].visible = true;
                balls[37].velocity = new Vector3((float)(randomiser.Next(12) + 8), 0, 0);
                balls[38].visible = true;
                balls[38].velocity = new Vector3((float)(randomiser.Next(12) + 8), 0, 0);

                balls[39].visible = true;
                balls[39].velocity = new Vector3((float)(randomiser.Next(12) + 8), 0, 0);

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);
                }

                collectable = new sprite2d(Content, "car", 2980, 205, 0.1f, Color.White, true);

                collectable2 = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
            }
            if (levelon == 6)
            {
                gameover = true;
            }
        }
示例#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")) // load in high score file
            {
                string line;
                StreamReader sr = new StreamReader(@"highscore.txt");
                line = sr.ReadLine();// loads sr into th evarible line
                sr.Close(); // closes the stream reader
                line = line.Trim();// trimss any excess white space
                highscore = Convert.ToInt32(line);// converts string to int 
            }

            loadbackgrounds(ref background, "backgroundcave", 0, 0, 0); // loads the background image position and size based on the background void
            background.velocity = new Vector3(-1, 0, 0); // moves the background from right to  left

            loadsprites(ref scorpionsting, "splat", 0, 0, 0.2f);// loads the scorpoion image and its position and its size 
            scorpionsting.velocity = new Vector3(-5, 0, 0);// creats a velocity for the spider to attack from above

            background1.image = Content.Load<Texture2D>("backgroundcave");
            background1.position.Y = 0; // poitions background at the top of the screen
            background1.position.X = displaywidth; // poitions background at the left of the screen
            background1.rect.Width = displaywidth; // sets the backgrounds size to the size of displaywidth
            background1.rect.Height = displayheight; // sets the backgrounds size to the size of displayheight
            background1.velocity = new Vector3(-1, 0, 0); // moves the background from right to  left


            loadsprites(ref gameoverimage, "gameoverimage", 0, 0, 1);// loads th egameoverimges image , positionand size;
     

            spiderfalls = Content.Load<SoundEffect>("crisps walls"); //load sound effect for enemys


            loadsprites(ref ship, "spaceship", 0, 0, 0.25f); // loads  based on the loadsprites
            ship.power = 1.5f; // gives the player ship some power

            loadsprites(ref spider, "spider", randomiser.Next(400) + 80, -30, 1); // loads  based on the loadsprites
            spider.velocity = new Vector3(0, 4, 0); // sets the velocity of which the spdier should attack at

            for (int y = 0; y < playerbullet.Count(); y++) // creats a for loop that will run playerbullet amout of time (see varible)
            {
                loadsprites(ref playerbullet[y], "bullet2", 0, 0, 0.1f); // loads  based on the loadsprites
                playerbullet[y].velocity = new Vector3(5, 0, 0); // sets the velocity of the player bullet
            }

            for (int y = 0; y < enemybullet.Count(); y++) // creats a for loop that will run enemybullet amout of time (see varible)
            {
                loadsprites(ref enemybullet[y], "bullet", 0, 0, 0.2f); // loads  based on the loadsprites
                enemybullet[y].velocity = new Vector3(-5, 0, 0); // sets the velocity of the first enemys bullet
            }
            for (int y = 0; y < enemybullet2.Count(); y++)  // creats a for loop that will run enemybullet2 amout of time (see varible)
            {
                loadsprites(ref enemybullet2[y], "bullet3", 0, 0, 0.1f); // loads  based on the loadsprites
                enemybullet2[y].velocity = new Vector3(-5, 0, 0); // sets the velocity of the 2nd enemys bullet
            }

            for (int y = 0; y < enemyship.Count(); y++) // creats a for loop that will run enemyship amout of time (see varible)
            {
                loadsprites(ref enemyship[y], "enemyship1", 0, 0, 0.5f); // loads  based on the loadsprites
               

            }


            for (int y = 0; y < enemyship2.Count(); y++) // creats a for loop that will run enemyship2 amout of time (see varible)
            {
                loadsprites(ref enemyship2[y], "enemyship2", 0, 0, 1f); // loads  based on the loadsprites
    

            }

            for (int y = 0; y < playerbullet2.Count(); y++) // creats a for loop that will run playerbullet2 amout of time (see varible)
            {
                playerbullet2[y].velocity = new Vector3(0, -10, 0); // loads  based on the loadsprites
                loadsprites(ref playerbullet2[y], "bulletup", 0, 0, 0.15f); // sets the velocity of the players 2nd bullet

            }

            loadsprites(ref scorpion, "scorpion", randomiser.Next(400) + 30, 530, 0.15f); // loads  based on the loadsprites
            scorpion.velocity = new Vector3(0, -15, 0); // sets the velocity of the scorpion 





            for (int y = 0; y < spiderweb.Count(); y++) // creats a for loop that will run spiderweb amout of time (see varible)
            {
                spiderweb[y].velocity = new Vector3(0, 10, 0); // load spider web into the game
                loadsprites(ref spiderweb[y], "spiderweb", 0, 0, 0.1f); // setes the spider web velocity
            }

            explosion1 = new animation(Content, "explosion", 0, 0, 0.5f, Color.White, false, 24, 1, 6, false, false, false); // loads animation
            explosion2 = new animation(Content, "cast_003", 0, 0, 0.5f, Color.White, false, 24, 4, 5, false, false, false); // loads animation
            goodexplosion = new animation(Content, "darkness_001", 0, 0, 0.2f, Color.White, false, 24, 5, 6, false, false, false); // loads animation
            spiderdeath = new animation(Content, "explosion2", 0, 0, 0.5f, Color.White, false, 24, 2, 5, false, false, false); // loads animation

            mainfont = Content.Load<SpriteFont>("font"); // load font 
            song = Content.Load<SoundEffect>("superfly"); // load sound track into game
            music = song.CreateInstance();// allow for sound trck to be played
            gooddeath = Content.Load<SoundEffect>("goodguylaserdeath"); //load sound effect for player death
            goodfire = Content.Load<SoundEffect>("laserfire"); //load sound effect for players guns
            badfire = Content.Load<SoundEffect>("laserfire2"); //load sound effect for enemys guns
            resetgame();
            resetship();
        }
示例#3
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);

            // 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
            }
            Array.Sort(highscores, highscorenames);
            Array.Reverse(highscores);
            Array.Reverse(highscorenames);

            collectgoodfood = new animation(Content, "magic_008", 0, 0, 2, Color.White, false, 26, 3, 5);
            collectbadfood = new animation(Content, "magic_008", 0, 0, 2, Color.Red, false, 26, 3, 5);

            death = Content.Load<SoundEffect>("ballhit");
            mainfont = Content.Load<SpriteFont>("font");                                    //Loads Font

            background.image = Content.Load<Texture2D>("Main_Menu");                         //Loads Menu Background
            background.rect.Y = 0;
            background.rect.X = 0;
            background.rect.Width = displaywidth;
            background.rect.Height = displayheight;

            controls.image = Content.Load<Texture2D>("controls");                           //Loads Controls
            controls.rect.Y = 0;
            controls.rect.X = 0;
            controls.rect.Width = displaywidth;
            controls.rect.Height = displayheight;

            soundtrack1 = Content.Load<SoundEffect>("explosive_attack");
            music1 = soundtrack1.CreateInstance();
            music1.IsLooped = true;
            music1.Volume = 0.35f;

            gamebackground.image = Content.Load<Texture2D>("desert_BG");                    //Loads Game Background
            gamebackground.position.Y = 0;
            gamebackground.position.X = 0;
            gamebackground.rect.Width = displaywidth;
            gamebackground.rect.Height = displayheight;
            gamebackground.velocity = new Vector3(-2, 0, 0);

            gamebackground2.image = Content.Load<Texture2D>("desert_BG");                   //Loads Scrolling Background
            gamebackground2.position.Y = 0;
            gamebackground2.position.X = displaywidth;
            gamebackground2.rect.Width = displaywidth;
            gamebackground2.rect.Height = displayheight;
            gamebackground2.velocity = new Vector3(-2, 0, 0);

            gameoverimage.image = Content.Load<Texture2D>("gameoverimage");
            gameoverimage.rect.Y = 0;
            gameoverimage.rect.X = 0;
            gameoverimage.rect.Width = displaywidth;
            gameoverimage.rect.Height = displayheight;

            vicscreen.image = Content.Load<Texture2D>("victoryscreen1");
            vicscreen.rect.Y = 0;
            vicscreen.rect.X = 0;
            vicscreen.rect.Width = displaywidth;
            vicscreen.rect.Height = displayheight;

            loadsprites(ref menuoptions[0, 0], "START", displaywidth / 2, 200, 1.25f);                    //Loads Menu Options
            loadsprites(ref menuoptions[0, 1], "START LOGO", displaywidth / 2, 200, 1.25f);
            loadsprites(ref menuoptions[1, 0], "CONTROLS (2)", displaywidth / 2, 300, 1.25f);
            loadsprites(ref menuoptions[1, 1], "CONTROLS BUTTON", displaywidth / 2, 300, 1.25f);
            loadsprites(ref menuoptions[2, 0], "HIGH SCORE", displaywidth / 2, 400, 1.25f);
            loadsprites(ref menuoptions[2, 1], "HIGH SCORE LOGO", displaywidth / 2, 400, 1.25f);
            loadsprites(ref menuoptions[3, 0], "EXIT", displaywidth / 2, 500, 1.25f);
            loadsprites(ref menuoptions[3, 1], "EXIT LOGO", displaywidth / 2, 500, 1.25f);

            playerjump = Content.Load<SoundEffect>("jump sound 1");
            bananacollect = Content.Load<SoundEffect>("collectgfood");

            menuchange = Content.Load<SoundEffect>("MENU A_Select");                        //Loads Menu Sounds
            menuselect = Content.Load<SoundEffect>("menuSound");

            for (int i = 0; i < numberofbadfood; i++)    // load bad foods
            {
                if (i < 20)
                {
                    bfood[i].image = Content.Load<Texture2D>("chipsPHG");

                }
                if (i >= 20 && i < 40)
                {
                    bfood[i].image = Content.Load<Texture2D>("CheeseburgerRage");

                }
                if (i >= 40 && i < numberofbadfood)
                {
                    bfood[i].image = Content.Load<Texture2D>("evilHotdog");

                }

                bfood[i].origin.Y = bfood[i].image.Height / 2;
                bfood[i].origin.X = bfood[i].image.Width / 2;
                bfood[i].position.Y = 640;
                bfood[i].position.X = 400;
                bfood[i].rect.Width = (int)(bfood[i].image.Width *0.3f);
                bfood[i].rect.Height = (int)(bfood[i].image.Height *0.27f);

            }

            for (int i = 0; i < numberofgoodfood; i++)
            {
                gfood[i].image = Content.Load<Texture2D>("banana");
                gfood[i].origin.Y = gfood[i].image.Height / 2;
                gfood[i].origin.X = gfood[i].image.Width / 2;
                gfood[i].position.Y = 300;
                gfood[i].position.X = 1200;
                gfood[i].rect.Width = (int)(gfood[i].image.Width / 2);
                gfood[i].rect.Height = (int)(gfood[i].image.Height / 2);
                gfood[i].velocity = new Vector3(-5, 0, 0);
            }

            List<Texture2D> textures = new List<Texture2D>();
            textures.Add(Content.Load<Texture2D>("circle"));
            textures.Add(Content.Load<Texture2D>("star"));
            textures.Add(Content.Load<Texture2D>("diamond"));
            for (int i = 0; i < numberofgoodfood; i++)
            particleEngine[i] = new ParticleEngine(textures, new Vector2(450, 420));

            spawnfood();
        }
示例#4
0
        void resetlevel()// used for moving the player on to the next level
        {
            // Level 1
            if (levelon == 1)
            {

                megaman.position = new Vector3(50, 500, 0);

                backgscroll = new scrollingbackground(Content, "backgroundforscrolling", 4f, 3, 1);// scrools back ground
                backgscroll.makehorizontal(displayheight);


                balls[0] = new sprite2d(Content, "ball", 340, displayheight - 50, 0.2f, Color.White, true);// move balls
                for (int i = 1; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, true);

                }


                balls[5] = new sprite2d(Content, "ball", 500 + (5 * 335), displayheight - 25, 0.2f, Color.White, false);
                balls[6] = new sprite2d(Content, "ball", 500 + (8 * 335), displayheight - 25, 0.2f, Color.White, false);

                for (int i = 7; i < numberofballs; i++)
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, false);

                for (int i = 7; i < numberofballs; i++)// make unsed balls invisible
                    balls[7].visible = false;

                platforms[0] = new sprite2d(Content, "red", 340, displayheight - 20, 1, Color.White, true);// draw platforms

                for (int i = 1; i < 5; i++)
                    platforms[i] = new sprite2d(Content, "red", 500 + (i * platforms[0].rect.Width) * 5, displayheight - 20, 1, Color.White, true);
                platforms[5] = new sprite2d(Content, "redflip", 339, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[6] = new sprite2d(Content, "redflip", 834, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[7] = new sprite2d(Content, "redflip", 839 + 330, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[8] = new sprite2d(Content, "redflip", 845 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[9] = new sprite2d(Content, "redflip", 849 + 330 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, true);

                platforms[10] = new sprite2d(Content, "red", 849 + 990 + 600, displayheight - platforms[0].rect.Height / 2, 1, Color.White, true);
                platforms[11] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight - 200, 1, Color.White, true);
                platforms[12] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight - 200, 1, Color.White, true);
                platforms[13] = new sprite2d(Content, "redflip", 3830, displayheight - 20, 1, Color.White, false);

                for (int i = 14; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight + 500 + 200, 1, Color.White, false);


                spikes[0] = new sprite2d(Content, "spikes", 100, 500, 1, Color.White, false);// set the unsued spikes visiblity to false

                for (int i = 1; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", platforms[9].rect.X + 330, displayheight - spikes[0].rect.Height / 2, 1, Color.White, false);


                for (int i = 0; i < numberofballs; i++)
                {
                    do
                    {
                        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(20) + 1) / 2, 0);
                    } while (balls[i].velocity.Y == 0);// give the ball a random velocity ip and down
                }
                //for (int i = 0; i < numberofballs; i++)
                //{
                //    balls[i].velocity = new Vector3(0, -2, 0);
                //}

                for (int i = 0; i < numofsuperballs; i++)
                    superballs[i].visible = false;
                for (int i = 0; i < numofsuperballs; i++)
                {

//                    superballs[i].position = new Vector3(500 + (5 * 335), displayheight - 25, 0);
                    superballs[0].position = new Vector3(500 + (5 * 335), displayheight - 25, 0);
                    superballs[1].position = new Vector3(3630, displayheight - 25, 0);
                    superballs[0].visible = true;
                    superballs[1].visible = true;
                    
                }

                for (int i = 5; i < numberofballs; i++)
                    balls[i].velocity = new Vector3(2, 0, 0);

                collectable = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);// Draw these as true when in use

                collectable2[0] = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
                collectable2[1] = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);


                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);// used for checking when the player has reached the end.
                }
            }

            // Level 2
            if (levelon == 2)// loads level 2
            {
                backgscroll = new scrollingbackground(Content, "skypan2", 4f, 1, 1);// moves back ground
                backgscroll.makehorizontal(displayheight);

                for (int i = 0; i < numofsuperballs; i++)
                    superballs[i].visible = false;
                megaman.position = new Vector3(50, 500, 0);

                balls[0] = new sprite2d(Content, "ball", 340, displayheight - 50, 0.2f, Color.White, true);
                for (int i = 0; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, false);

                }
                //balls[5] = new sprite2d(Content, "ball", 500 + (5 * 335), displayheight - 25, 0.2f, Color.White, false);
                //balls[6] = new sprite2d(Content, "ball", 500 + (8 * 335), displayheight - 25, 0.2f, Color.White, false);

                platforms[0] = new sprite2d(Content, "green", 340, displayheight - 20, 1, Color.White, true);

                for (int i = 1; i < 5; i++)
                    platforms[i] = new sprite2d(Content, "green", 500 + (i * platforms[0].rect.Width) * 5, displayheight - 20 - (i * 40), 1, Color.White, true);
                for (int i = 5; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "green", platforms[4].rect.X + 330 + (i * platforms[3].rect.Width), displayheight / 2, 1, Color.White, true);
                //platforms[6] = new sprite2d(Content, "greenflip", 834, platforms[0].rect.Height / 2, 1, Color.White, false);
                //platforms[7] = new sprite2d(Content, "greenflip", 839 + 330, platforms[0].rect.Height / 2, 1, Color.White, false);
                //platforms[8] = new sprite2d(Content, "greenflip", 845 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, false);
                //platforms[9] = new sprite2d(Content, "greenflip", 849 + 330 + 330 + 330, platforms[0].rect.Height / 2, 1, Color.White, false);

                platforms[10] = new sprite2d(Content, "green", platforms[4].rect.X + 330, displayheight / 2, 1, Color.White, true);
                platforms[11] = new sprite2d(Content, "green", platforms[9].rect.X + 330, displayheight / 2, 1, Color.White, true);
                platforms[12] = new sprite2d(Content, "greenflip", platforms[9].rect.X + 330, displayheight - 400, 1, Color.White, true);

                for (int i = 13; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "redflip", 849 + 990 + 600, displayheight + 500 + 200, 1, Color.White, false);

                collectable = new sprite2d(Content, "key", platforms[9].rect.X + 330, displayheight - 300, 0.2f, Color.White, true);

                collectable2[0] = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
                collectable2[1] = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);

                for (int i = 0; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", platforms[9].rect.X + 330, displayheight - spikes[i].rect.Height / 2, 1, Color.White, true);

                animation powerup = new animation(Content, "cast_006", platforms[9].rect.X + 330, displayheight - 200, 0.1f, Color.White, true, 25, 6, 6);
                powerup.start(new Vector3(200, 300, 0));// decided not to use this 

                for (int i = 0; i < numofsuperballs; i++)
                    superballs[i].visible = false;

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);
                }


                //for (int i = 0; i < numberofballs; i++)
                //{
                //    do
                //    {
                //        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(20) + 1) / 2, 0);
                //    } while (balls[i].velocity.Y == 0);
                //}
            }


            // Level 3
            if (levelon == 3)// loads level 3
            {
                backgscroll = new scrollingbackground(Content, "sky", 4f, 3, 1);
                backgscroll.makehorizontal(displayheight);

                megaman.position = new Vector3(50, 500, 0);

                for (int i = 0; i < numofsuperballs; i++)
                    superballs[i].visible = false;

                balls[0] = new sprite2d(Content, "ball", 340, displayheight - 50, 0.2f, Color.White, false);
                for (int i = 1; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 500 + (i * 335), displayheight - 50, 0.2f, Color.White, false);

                }
                balls[5] = new sprite2d(Content, "ball", 500 + (5 * 335), displayheight - 25, 0.2f, Color.White, true);
                balls[6] = new sprite2d(Content, "ball", 500 + (8 * 335), displayheight - 25, 0.2f, Color.White, true);

                platforms[0] = new sprite2d(Content, "diamond", 50, displayheight - 100, 1, Color.White, true);
                for (int i = 1; i < 5; i++)
                    platforms[i] = new sprite2d(Content, "diamond", 80 + (i * platforms[0].rect.Width) * 4, displayheight - 100, 1, Color.White, true);

                for (int i = 5; i < 8; i++)
                    platforms[i] = new sprite2d(Content, "diamond", (i * platforms[0].rect.Width - 50) * 5, displayheight - 20 - (i * 40), 1, Color.White, true);


                platforms[10] = new sprite2d(Content, "diamond", (platforms[9].rect.X - 400), displayheight - 200, 1, Color.White, true);
                platforms[11] = new sprite2d(Content, "diamond", platforms[9].rect.X - 50, displayheight - 150, 1, Color.White, true);
                platforms[8] = new sprite2d(Content, "red", platforms[7].rect.X, displayheight - 75, 1, Color.White, true);
                platforms[9] = new sprite2d(Content, "diamond", platforms[7].rect.X + 60, displayheight - 120, 1, Color.White, true);
                platforms[12] = new sprite2d(Content, "diamond", platforms[9].rect.X + 1000, displayheight - 200, 1, Color.White, true);
                for (int i = 13; i < 17; i++)
                    platforms[i] = new sprite2d(Content, "triangle", i * platforms[9].rect.Width + 2700, displayheight - 300, 1, Color.White, true);

                platforms[20] = new sprite2d(Content, "diamond", platforms[19].rect.Width + 3400, displayheight - 100, 1, Color.White, true);

                for (int i = 21; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "triangle", 849 + 990 + 600, displayheight + 500 + 200, 1, Color.White, false);

                collectable = new sprite2d(Content, "key", platforms[9].rect.X + 100, 100, 0.2f, Color.White, true);
                collectable2[0] = new sprite2d(Content, "clock", 2285, 400, 0.3f, Color.White, true);

                spikes[0] = new sprite2d(Content, "spikes", 100, displayheight - 40, 1, Color.White, true);

                for (int i = 1; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", 100 + (i * spikes[0].rect.Width), displayheight - 40, 1, Color.White, true);


                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, (i * 35), 1, Color.White, false);
                }


                for (int i = 0; i < numberofballs; i++)
                {
                    do
                    {
                        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(40) + 1) / 2f, 0);
                    } while (balls[i].velocity.Y == 0);
                }

            }
            if (levelon == 4)// load level 5
            {
                backgscroll = new scrollingbackground(Content, "backgroundscrolling2", 4f, 2, 1);
                backgscroll.makehorizontal(displayheight);

                for (int i = 0; i < numofsuperballs; i++)
                    superballs[i].visible = false;

                megaman.position = new Vector3(50, 500, 0);


                for (int i = 0; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "red", (i * 70), displayheight + 100 + platforms[i].rect.Height / 2, 1, Color.White, false);
                for (int i = 56; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "redflip", platforms[0].rect.X + (10 * 1), 100 + platforms[i].rect.Height / 2, 1, Color.White, false);


                for (int i = 0; i < numberofspikes; i++)
                    spikes[i] = new sprite2d(Content, "spikes", 100 + (i * spikes[0].rect.Width), displayheight + 340, 1, Color.White, false);

                //balls[0] = new sprite2d(Content, "ball", 50, displayheight - 50, 0.2f, Color.White, true);
                for (int i = 7; i < numberofballs; i++)
                {
                    //balls[1] = new sprite2d(Content, "ball", 830, displayheight / 2, 0.2f, Color.White, true);
                    balls[i] = new sprite2d(Content, "ball", 40 + (i * 120), displayheight - 50, 0.2f, Color.White, true);

                }

                balls[39] = new sprite2d(Content, "ball", 340, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, false);
           

                for (int i = 0; i < numberofballs; i++)
                {
                    do
                    {
                        balls[i].velocity = new Vector3(0, (float)(randomiser.Next(40) + 1) / 2f, 0);
                    } while (balls[i].velocity.Y == 0);
                }
                balls[39].velocity = new Vector3(8, 0, 0);
                //superballs[3].velocity = new Vector3(8, 0, 0);

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);
                }

                collectable = new sprite2d(Content, "key", 2980, 205, 0.2f, Color.White, true);

                collectable2[0] = new sprite2d(Content, "saucer2", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
                collectable2[1] = new sprite2d(Content, "saucer2", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
            }
            if (levelon == 5)// load level 5
            {
                backgscroll = new scrollingbackground(Content, "skypan2", 4f, 1, 1);
                backgscroll.makehorizontal(displayheight);

                //for (int i = 0; i < numofsuperballs; i++)
                //    superballs[i].visible = false;

                for (int i = 0; i < numofsuperballs; i++)
                {
                    if (numofsuperballs < 2)
                        superballs[i].visible = false;
                    else
                        superballs[i].visible = true;

                    //superballs[i].velocity = new Vector3(100, 0, 0);
                }
                superballs[3].visible = false;
                
                superballs[2].position = new Vector3(1140, displayheight - 25, 0);
                superballs[3].position = new Vector3(1500, displayheight - 25, 0);
                superballs[4].position = new Vector3(2500, displayheight - 25, 0);
              

                megaman.position = new Vector3(50, 500, 0);

                platforms[0] = new sprite2d(Content, "orange", 200, 350, 1, Color.White, true);
                for (int i = 0; i < numberofplatforms; i++)
                    platforms[i] = new sprite2d(Content, "orange", (i * 700), 350, 1, Color.White, true);


                //balls[37] = new sprite2d(Content, "ball", 540, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, false);

                //balls[38] = new sprite2d(Content, "ball", 1500, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, false);
                //balls[39] = new sprite2d(Content, "ball", 2500, displayheight - balls[39].rect.Height / 2, 0.2f, Color.White, false);

                for (int i = 0; i < numberofballs; i++)
                {
                    balls[i].visible = false;
                }
                //balls[37].visible = true;
                //balls[37].velocity = new Vector3((float)(randomiser.Next(12) + 8), 0, 0);
                //balls[38].visible = true;
                //balls[38].velocity = new Vector3((float)(randomiser.Next(12) + 8), 0, 0);

                //balls[39].visible = true;
                //balls[39].velocity = new Vector3((float)(randomiser.Next(12) + 8), 0, 0);

                platforms[16] = new sprite2d(Content, "orange", 3780, displayheight - 25, 1, Color.White, false);
                platforms[17] = new sprite2d(Content, "orange", 100, displayheight - 25, 1, Color.White, false);

                for (int i = 0; i < numberofends; i++)
                {
                    ends[i] = new sprite2d(Content, "green", 3830, displayheight - (i * 35), 1, Color.White, false);
                }

                collectable = new sprite2d(Content, "key", 2980, 205, 0.2f, Color.White, true);

                collectable2[0] = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
                collectable2[1] = new sprite2d(Content, "car", platforms[9].rect.X + 330, displayheight - 300, 1, Color.White, false);
            }
            if (levelon == 6)/// if player gets here the game will end 
            {
                gameover = true;

            }
        }
示例#5
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();
                sr.Close();
                line = line.Trim();
                highscore = Convert.ToInt32(line);
            }

            mainfont = Content.Load<SpriteFont>("font");

            explosion = new animation(Content, "fire_001", 0, 0, .5f, Color.White, false, 24, 4, 5, false, false,false);
            death = new animation(Content, "fire_002", 0, 0, 1, Color.White, false, 24, 5, 5, false, false, false);
            background.image = Content.Load<Texture2D>("universe");
            background.rect.X = 0;
            background.rect.Y = 0;
            background.rect.Width = displaywidth;
            background.rect.Height = displayheight;

            gameoverimage.image = Content.Load<Texture2D>("gameover");
            gameoverimage.rect.Y = 0;
            gameoverimage.rect.X = 0;
            gameoverimage.rect.Width = displaywidth;
            gameoverimage.rect.Height = displayheight;

            gameoversound = Content.Load<SoundEffect>("explosion");

            laserbase.image = Content.Load<Texture2D>("goodship");
            laserbase.size = 0.3f;
            laserbase.origin.X = laserbase.image.Width / 2;
            laserbase.origin.Y = laserbase.image.Height / 2;
            laserbase.rect.Width = (int)(laserbase.image.Width * laserbase.size);
            laserbase.rect.Height = (int)(laserbase.image.Height * laserbase.size);
            laserbase.power = 1f;

            for (int i = 0; i < badlaser.Count(); i++)
            {
                badlaser[i].image = Content.Load<Texture2D>("invader_bullet");
                badlaser[i].size = 0.3f;
                badlaser[i].origin.X = badlaser[i].image.Width/2;
                badlaser[i].origin.Y = badlaser[i].image.Height / 2;
                badlaser[i].rect.Width = (int)(badlaser[i].image.Width * badlaser[i].size);
                badlaser[i].rect.Height = (int)(badlaser[i].image.Height * badlaser[i].size);
                badlaser[i].velocity = new Vector3(0, 10, 0);

            }
            badlasersound = Content.Load<SoundEffect>("laser");
            badhit = Content.Load<SoundEffect>("ballhit");

            goodlaser.image = Content.Load<Texture2D>("tank_bullet_1");
            goodlaser.size = 0.3f;
            goodlaser.origin.X = goodlaser.image.Width / 2;
            goodlaser.origin.Y = goodlaser.image.Height / 2;
            goodlaser.rect.Height = (int)(goodlaser.image.Height * goodlaser.size);
            goodlaser.rect.Width = (int)(goodlaser.image.Width * goodlaser.size);
            goodlaser.velocity = new Vector3(0, -5, 0);

            goodlasersound = Content.Load<SoundEffect>("laser");
            goodhit = Content.Load<SoundEffect>("crash");

            for (int y = 0; y < rows; y++)
                for (int x = 0; x < columns; x++)
                {
                    invader[x, y].image = Content.Load<Texture2D>("invader");
                    invader[x, y].size = 0.12f;
                    invader[x, y].origin.X = invader[x, y].image.Width / 2;
                    invader[x, y].origin.Y = invader[x, y].image.Height / 2;
                    invader[x, y].rect.Width = (int)(invader[x, y].image.Width * 0.14);
                    invader[x, y].rect.Height = (int)(invader[x, y].image.Height * invader[x, y].size);
                    invader[x, y].power = 2;
                }

            sheild[0].image = Content.Load < Texture2D>("sheild1");
            sheild[1].image = Content.Load<Texture2D>("sheild2");
            sheild[2].image = Content.Load<Texture2D>("sheild3");
            sheild[3].image = Content.Load<Texture2D>("sheild4");

            for (int s = 0; s < sheild.Count(); s++)
            {
                sheild[s].origin.X = sheild[s].image.Width / 2;
                sheild[s].origin.Y = sheild[s].image.Height / 2;
                sheild[s].size = 0.4f;
                sheild[s].rect.Width = (int)(sheild[s].image.Width * sheild[s].size);
                sheild[s].rect.Height = (int)(sheild[s].image.Height * sheild[s].size);
            }

            sheild[0].rect.X = 100;
            sheild[0].rect.Y = displayheight - 155;
            sheild[1].rect.X = 300;
            sheild[1].rect.Y = displayheight - 155;
            sheild[2].rect.X = 500;
            sheild[2].rect.Y = displayheight - 155;
            sheild[3].rect.X = 700;
            sheild[3].rect.Y = displayheight - 155;

            for (int s = 0; s < sheild.Count(); s++)
            {
                sheild[s].bsphere = new BoundingSphere(new Vector3((float)sheild[s].rect.X, (float)sheild[s].rect.Y, 0), sheild[s].rect.Width / 2);
            }
            resetgame();
        }