예제 #1
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);

            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();
        }
예제 #2
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;
            }
        }
예제 #3
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;

            }
        }