Esempio n. 1
0
        public override void LoadContent()
        {
            scrolling1 = new Scrolling(Content.Load <Texture2D>("skyMenu"), new Rectangle(0, 0, 800, 600));
            scrolling2 = new Scrolling(Content.Load <Texture2D>("skyMenu"), new Rectangle(800, 0, 800, 600));
            texBack    = texFromFile(graphicsDevice, dir + "menu1.png");
            texBall    = texFromFile(graphicsDevice, dir + "ballMenu.png");
            back1      = new ImageBackground(texBack, Color.White, graphicsDevice);

            texBack1 = texFromFile(graphicsDevice, dir + "help.png");
            back2    = new ImageBackground(texBack1, Color.White, graphicsDevice);



            anmiationList = new SpriteList();
            for (int y = 0; y < 2; y++)
            {
                anmiation1 = new Sprite3(true, texBall, 190, 265 + b);
                anmiation1.setXframes(3);
                anmiation1.setYframes(1);
                anmiation1.setWidthHeight(32, 32);
                Vector2[] seq = new Vector2[3];
                seq[0].X = 1; seq[0].Y = 0;
                seq[1].X = 2; seq[1].Y = 0;
                seq[2].X = 0; seq[2].Y = 0;

                anmiation1.setAnimationSequence(seq, 0, 2, 15);
                anmiation1.animationStart();
                anmiationList.addSpriteReuse(anmiation1);

                b = b + 56;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Make a boom sprite if boomn size == 0 then default size is used
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="boomKind"></param>
        /// <param name="boomSize"></param>
        /// <returns></returns>
        public Sprite3 makeBoom(int x, int y, int boomKind, float boomSize)
        {
            //Texture2DSequence fs = new Texture2DSequence(boomSpriteSheets[boomKind]);
            //fs.setAnimationSequence(frameSeqs[boomKind].firstFrame,frameSeqs[boomKind].lastFrame,frameSeqs[boomKind].ticksBetweenFrames);
            Sprite3         boom = new Sprite3(true, boomImages[boomKind], x, y);
            GCG_SpriteSheet ss   = boomSpriteSheets[boomKind];

            boom.setXframes(ss.getXframes());
            boom.setYframes(ss.getYframes());
            int q = ss.getXframes() * ss.getYframes();

            Vector2[] animSeq = new Vector2[q];
            int       ctr     = 0;

            for (int yy = 0; yy < ss.getYframes(); yy++)
            {
                for (int xx = 0; xx < ss.getXframes(); xx++)
                {
                    animSeq[ctr].X = xx;
                    animSeq[ctr].Y = yy;
                    ctr++;
                }
            }
            boom.setAnimationSequence(animSeq, 0, q - 1, 4);
            //boom.setFrameSource(boomSpriteSheets[boomKind], true);
            if (boomSize > 0)
            {
                boom.setWidthHeight(boomSize, boomSize);
            }
            boom.animationStart();
            //boom.animInfo = fs;
            boom.setAnimFinished(2);
            return(boom);
        }
Esempio n. 3
0
        //Adds explosion to particle list
        public void AddExplosion(int x, int y)
        {
            float scale   = 0.6f;
            float xOffset = -10;
            float yOffset = -5;

            Sprite3 newExplosion = new Sprite3(true, explosionTex, x + xOffset, y + yOffset);

            newExplosion.setXframes(7);
            newExplosion.setYframes(3);
            newExplosion.setWidthHeight(896 / 7 * scale, 384 / 3 * scale);

            Vector2[] anim = new Vector2[21];
            anim[0].X  = 0; anim[0].Y = 0;
            anim[1].X  = 1; anim[1].Y = 0;
            anim[2].X  = 2; anim[2].Y = 0;
            anim[3].X  = 3; anim[3].Y = 0;
            anim[4].X  = 4; anim[4].Y = 0;
            anim[5].X  = 5; anim[5].Y = 0;
            anim[6].X  = 6; anim[6].Y = 0;
            anim[7].X  = 0; anim[7].Y = 1;
            anim[8].X  = 1; anim[8].Y = 1;
            anim[9].X  = 2; anim[9].Y = 1;
            anim[10].X = 3; anim[10].Y = 1;
            anim[11].X = 4; anim[11].Y = 1;
            anim[12].X = 5; anim[12].Y = 1;
            anim[13].X = 6; anim[13].Y = 1;
            anim[14].X = 0; anim[14].Y = 2;
            anim[15].X = 1; anim[15].Y = 2;
            anim[16].X = 2; anim[16].Y = 2;
            anim[17].X = 3; anim[17].Y = 2;
            anim[18].X = 4; anim[18].Y = 2;
            anim[19].X = 5; anim[19].Y = 2;
            anim[20].X = 6; anim[20].Y = 2;
            newExplosion.setAnimationSequence(anim, 0, 20, 2);
            newExplosion.setAnimFinished(2); // make it inactive and invisible
            newExplosion.animationStart();

            particleList.addSpriteReuse(newExplosion);

            soundExplosionLimit.playSoundIfOk();
        }
Esempio n. 4
0
        void createExplosion(int x, int y)
        {
            float scale   = 0.99f;
            int   xoffset = -2;
            int   yoffset = -20;

            Sprite3 s = new Sprite3(true, texBoom, x + xoffset, y + yoffset);

            s.setXframes(7);
            s.setYframes(3);
            s.setWidthHeight(896 / 7 * scale, 384 / 3 * scale);

            Vector2[] anim = new Vector2[21];
            anim[0].X  = 0; anim[0].Y = 0;
            anim[1].X  = 1; anim[1].Y = 0;
            anim[2].X  = 2; anim[2].Y = 0;
            anim[3].X  = 3; anim[3].Y = 0;
            anim[4].X  = 4; anim[4].Y = 0;
            anim[5].X  = 5; anim[5].Y = 0;
            anim[6].X  = 6; anim[6].Y = 0;
            anim[7].X  = 0; anim[7].Y = 1;
            anim[8].X  = 1; anim[8].Y = 1;
            anim[9].X  = 2; anim[9].Y = 1;
            anim[10].X = 3; anim[10].Y = 1;
            anim[11].X = 4; anim[11].Y = 1;
            anim[12].X = 5; anim[12].Y = 1;
            anim[13].X = 6; anim[13].Y = 1;
            anim[14].X = 0; anim[14].Y = 2;
            anim[15].X = 1; anim[15].Y = 2;
            anim[16].X = 2; anim[16].Y = 2;
            anim[17].X = 3; anim[17].Y = 2;
            anim[18].X = 4; anim[18].Y = 2;
            anim[19].X = 5; anim[19].Y = 2;
            anim[20].X = 6; anim[20].Y = 2;
            s.setAnimationSequence(anim, 0, 20, 4);
            s.setAnimFinished(2); // make it inactive and invisible
            s.animationStart();

            booms.addSpriteReuse(s); // add the sprite
        }
Esempio n. 5
0
        //Somewhere to store previous keyboard information so we can detect a single key click(as opposed to the 30 a second we get on a key depress)



        public override void LoadContent()
        {
            spriteBatch = new SpriteBatch(graphicsDevice);

            //
            random = new Random();

            //  font1 = Content.Load<SpriteFont>("Fontey");

            Particle1 = Util.texFromFile(graphicsDevice, Dir.dir + "Particle1.png");
            Particle2 = Util.texFromFile(graphicsDevice, Dir.dir + "Particle2.png");
            Particle3 = Util.texFromFile(graphicsDevice, Dir.dir + "Particle3.png");
            Particle4 = Util.texFromFile(graphicsDevice, Dir.dir + "ParticleArrow.png");
            Particle5 = Util.texFromFile(graphicsDevice, Dir.dir + "Cloud8.png");
            Particle6 = Util.texFromFile(graphicsDevice, Dir.dir + "Bug2.png");

            tex = Particle2;


            //

            font1         = Content.Load <SpriteFont>("SpriteFont1");
            texBack       = texFromFile(graphicsDevice, dir + "levelOneBack1.png");
            spider        = texFromFile(graphicsDevice, dir + "Bug.png");
            texpaddle     = texFromFile(graphicsDevice, dir + "paddle2.png");
            bee           = texFromFile(graphicsDevice, dir + "Bee2.png");
            texAnmiation1 = Util.texFromFile(graphicsDevice, dir + "coin3.png");
            texDragon     = Util.texFromFile(graphicsDevice, dir + "dragon.png");
            scrolling1    = new Scrolling(Content.Load <Texture2D>("skyMenu"), new Rectangle(0, 0, 800, 600));
            scrolling2    = new Scrolling(Content.Load <Texture2D>("skyMenu"), new Rectangle(800, 0, 800, 600));
            music         = Content.Load <SoundEffect>("MUSIC1");
            limSound      = new LimitSound(music, 3);
            bazooka       = Content.Load <SoundEffect>("bazooka_fire");
            baz           = bazooka.CreateInstance();

            LineBatch.init(graphicsDevice);


            dragonList = new SpriteList();
            for (int y = 0; y < 3; y++)
            {
                for (int i = 0; i < 5; i++)
                {
                    dragon = new Sprite3(true, texDragon, 250 + a, 80 + b);
                    dragon.setXframes(8);
                    dragon.setYframes(1);
                    dragon.setWidthHeight(32, 32);
                    //anmiation1.setBBToTexture();
                    dragon.setBB(7, 7, 130, 124);
                    Vector2[] seq1 = new Vector2[8];
                    seq1[0].X = 0; seq1[0].Y = 0;
                    seq1[1].X = 1; seq1[1].Y = 0;
                    seq1[2].X = 2; seq1[2].Y = 0;
                    seq1[3].X = 3; seq1[3].Y = 0;
                    seq1[4].X = 4; seq1[4].Y = 0;
                    seq1[5].X = 5; seq1[5].Y = 0;
                    seq1[6].X = 6; seq1[6].Y = 0;
                    seq1[7].X = 7; seq1[7].Y = 0;

                    dragon.setAnimationSequence(seq1, 0, 7, 10);
                    dragon.animationStart();
                    dragonList.addSpriteReuse(dragon);
                    a = a + 64;
                }
                a = 0;
                b = b + 80;
            }

            ballPos = new Vector2(xx, yy);
            paddle  = new Sprite3(true, texpaddle, xx, bot - texpaddle.Height);
            paddle.setBBToTexture();
            back1    = new ImageBackground(texBack, Color.White, graphicsDevice);
            playArea = new Rectangle(lhs, top, rhs - lhs, bot - top);      // width and height

            texBall = Util.texFromFile(graphicsDevice, dir + "ball2.png"); //***

            ball = new Sprite3(true, texBall, xx, yy);
            ball.setBBandHSFractionOfTexCentered(0.7f);
        }
Esempio n. 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            LineBatch.init(GraphicsDevice);

            // load all fonts for the splash screen and levels
            llFont = Content.Load <SpriteFont>("Large");
            mmFont = Content.Load <SpriteFont>("Medium");
            ssFont = Content.Load <SpriteFont>("Small");

            // load  textures from local content directory
            kcTexPath   = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/kittyCat.png";
            kittyCatTex = Util.texFromFile(GraphicsDevice, kcTexPath);

            bbTexPath     = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/Background.png";
            backgroundTex = Util.texFromFile(GraphicsDevice, bbTexPath);

            playerTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/KittyCatFrames.png";
            playerTex     = Util.texFromFile(GraphicsDevice, playerTexPath);

            doggyTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/CrazyDogFrames.png";
            doggyTex     = Util.texFromFile(GraphicsDevice, doggyTexPath);

            yarnTex = Content.Load <Texture2D>("Yarn");

            // position vector for the cat sprite on main splash screen
            kittyCatVec   = new Vector2(275, 50);
            titleVec      = new Vector2(100, 300);
            sloganVec     = new Vector2(290, 400);
            instructVec   = new Vector2(315, 425);
            levelIntroVec = new Vector2(250, 200);
            playerVec     = new Vector2(600, 400);
            doggyVec      = new Vector2(0, 400);


            // make the cat sprite for the main splash screen
            kittyCat = new Sprite3(true, kittyCatTex, kittyCatVec.X, kittyCatVec.Y);

            // prepare the crazy dog for level 2
            crazyDog = new Sprite3(false, doggyTex, doggyVec.X, doggyVec.Y);



            // color for the level text and alpha value
            ltCol = new Color(0, 255, 0, 1);
            // level text initialization
            levelText = new TextRenderable("Blabla", levelIntroVec, llFont, Color.Red);


            // source and destination rectangles for the scrolling background
            backgroundDest   = new Rectangle(0, 0, 800, 600);
            backgroundSource = new Rectangle(0, 0, 800, 600);

            // draw background
            background = new ScrollBackGround(backgroundTex, backgroundDest, backgroundSource, 5.0f, 2);

            // player vector and player texture

            playerSprite = new Sprite3(true, playerTex, playerVec.X, playerVec.Y);

            // initialize frame vector
            playerFrames = new Vector2[10];

            // frame vector values 1280x128

            playerFrames[0].X = 0; playerFrames[0].Y = 0;
            playerFrames[1].X = 1; playerFrames[1].Y = 0;
            playerFrames[2].X = 2; playerFrames[2].Y = 0;
            playerFrames[3].X = 3; playerFrames[3].Y = 0;
            playerFrames[4].X = 4; playerFrames[4].Y = 0;
            playerFrames[5].X = 5; playerFrames[5].Y = 0;
            playerFrames[6].X = 6; playerFrames[6].Y = 0;
            playerFrames[7].X = 7; playerFrames[7].Y = 0;
            playerFrames[8].X = 8; playerFrames[8].Y = 0;
            playerFrames[9].X = 9; playerFrames[9].Y = 0;

            // set all the parameters for the cute little kitty cat
            playerSprite.setWidthHeight(64, 64);
            playerSprite.setWidthHeightOfTex(1280, 128);
            playerSprite.setXframes(10);
            playerSprite.setYframes(0);
            playerSprite.setBB(0, 0, 128, 128);
            playerSprite.setAnimationSequence(playerFrames, 0, 9, 15);
            playerSprite.animationStart();

            // the parameters for the player sprite jumping
            playerJump      = false;
            playerJumpSpeed = 0;

            // store the initial positions of the player sprite
            prevPos.Y = playerVec.Y;
            prevPos.X = playerVec.X;

            // initialize sounds for the game
            jumpo      = Content.Load <SoundEffect>("Sounds/Boing");
            jumpoSound = new LimitSound(jumpo, 1);

            success      = Content.Load <SoundEffect>("Sounds/Success");
            successSound = new LimitSound(success, 1);

            barko      = Content.Load <SoundEffect>("Sounds/Growl");
            barkoSound = new LimitSound(barko, 1);

            kaching      = Content.Load <SoundEffect>("Sounds/Kaching");
            kachingSound = new LimitSound(kaching, 1);

            yowlin      = Content.Load <SoundEffect>("Sounds/Yowl");
            yowlinSound = new LimitSound(yowlin, 1);

            easterEgg = Content.Load <SoundEffect>("Sounds/OhWhatever");
            eeSound   = new LimitSound(easterEgg, 1);


            /// yarn ball sprite list
            ///
            ///
            ///
            ///
            ///
            ///

            yarnBalls = new SpriteList();

            Sprite3 yb;

            for (int i = 0; i < maxYarnBalls; i++)
            {
                // temporarily set to doggyVec for positioning - change later?
                yb = new Sprite3(true, yarnTex, doggyVec.X + i * 50, doggyVec.Y - i * 50);
                yb.setDeltaSpeed(new Vector2((float)(1 + rnd.NextDouble()), 0));
                yb.setWidthHeight(32, 32);
                yb.setWidthHeightOfTex(32, 32);
                yb.setHSoffset(new Vector2(32, 32));
                yb.setBBToTexture();
                yb.setMoveSpeed(2.1f);

                yarnBalls.addSpriteReuse(yb);
            }



            // initialize frame vector for dog
            doggyFrames = new Vector2[8];


            doggyFrames[0].X = 0; doggyFrames[0].Y = 0;
            doggyFrames[1].X = 1; doggyFrames[1].Y = 0;
            doggyFrames[2].X = 2; doggyFrames[2].Y = 0;
            doggyFrames[3].X = 3; doggyFrames[3].Y = 0;
            doggyFrames[4].X = 4; doggyFrames[4].Y = 0;
            doggyFrames[5].X = 5; doggyFrames[5].Y = 0;
            doggyFrames[6].X = 6; doggyFrames[6].Y = 0;
            doggyFrames[7].X = 7; doggyFrames[7].Y = 0;

            crazyDog.setWidthHeight(64, 64);
            crazyDog.setWidthHeightOfTex(1024, 128);
            crazyDog.setXframes(8);
            crazyDog.setYframes(0);
            crazyDog.setBB(0, 0, 128, 128);
            crazyDog.setAnimationSequence(playerFrames, 0, 7, 15);
            crazyDog.animationStart();
        }
Esempio n. 7
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);

            mainCamera = new Camera();



            //Load all the textures and fonts
            gameOverText         = Content.Load <SpriteFont>("MedievalFont");
            directions           = Content.Load <SpriteFont>("Gold");
            font                 = Content.Load <SpriteFont>("MedievalFont");
            difficultySelectText = Content.Load <SpriteFont>("MedievalFont");

            startText      = Content.Load <SpriteFont>("Gold");
            texStartBanner = Util.texFromFile(GraphicsDevice, dir + "startBanner.png");
            texGoldBanner  = Util.texFromFile(GraphicsDevice, dir + "goldBanner.png");
            texBook        = Util.texFromFile(GraphicsDevice, dir + "openBookWithText.png");
            texHorseRun    = Util.texFromFile(GraphicsDevice, dir + "horseRun.png");
            texEnemy       = Util.texFromFile(GraphicsDevice, dir + "Enemy.png");
            texBlood       = Util.texFromFile(GraphicsDevice, dir + "bloodSide.png");
            texArrow       = Util.texFromFile(GraphicsDevice, dir + "Arrow.png");
            texWorldMap    = Util.texFromFile(GraphicsDevice, dir + "FantasyWorldMap_2.png");

            //Define playarea
            playArea = new Rectangle(lhs, top, rhs - lhs, bot - top); // width and height

            //Load sprites and change size if necessary
            worldMap = new Sprite3(true, texWorldMap, -2000, -1000);
            worldMap.setWidthHeight(6400, 4800);
            book = new Sprite3(true, texBook, 50, 50);
            book.setWidthHeight(700, 500);
            startBanner = new Sprite3(true, texStartBanner, 0, 0);
            startBanner.setWidthHeight(800, 600);
            goldBanner = new Sprite3(true, texGoldBanner, 15, 15);
            goldBanner.setWidthHeight(130, 40);
            horse = new Sprite3(true, texHorseRun, xx, yy);



            //Load some empty spritelists
            enemies    = new SpriteList();
            bloodSplat = new SpriteList();
            horseRun   = new SpriteList();
            quiver     = new SpriteList();

            for (int a = 0; a < 5; a++)
            {
                arrow = new Sprite3(false, texArrow, 0, 0);
                arrow.setWidthHeight(arrow.getWidth() * 0.09f, arrow.getHeight() * 0.09f);
                quiver.addSpriteReuse(arrow);
            }

            //Used to change size of sprites
            float scale = 0.5f;


            //Player animation setup
            horse.setXframes(8);
            horse.setWidthHeight(1568 / 8 * scale, texHorseRun.Height * scale);
            horse.setBB(30, 10, (horse.getWidth() / scale) - 60, horse.getHeight() / scale - 20);
            for (int h = 0; h < anim.Length; h++)
            {
                anim[h].X = h;
            }
            horseRun.addSpriteReuse(horse);

            //enemy.setBBToTexture();

            //Enemy animation setup
            for (int k = 0; k < 100; k++)
            {
                enemy = new Sprite3(false, texEnemy, 850, 400);
                enemy.setXframes(10);
                enemy.setYframes(5);
                enemy.setWidthHeight(320 / 10, 160 / 5);
                enemy.setBB(0, 0, enemy.getWidth(), enemy.getHeight());
                int count = 0;
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        animEnemy[count].X = j;
                        animEnemy[count].Y = i;
                        count++;
                    }
                }
                enemy.setAnimationSequence(animEnemy, 20, 29, 15);
                enemy.setAnimFinished(0);
                enemy.animationStart();
                enemy.setVisible(false);
                enemies.addSpriteReuse(enemy);
            }
            //Load scrolling background images
            scrolling1 = new Scrolling(Util.texFromFile(GraphicsDevice, dir + "GPT Background 800x600.png"), new Rectangle(0, 0, 800, 600), scrollingSpeed);
            scrolling2 = new Scrolling(Util.texFromFile(GraphicsDevice, dir + "GPT Background2 800x600.png"), new Rectangle(800, 0, 800, 600), scrollingSpeed);
        }
Esempio n. 8
0
        public override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(graphicsDevice);
            weaponList  = new SpriteList(20);

            playerXLocation = Dir.rnd.Next(0, 1000);
            playerYLocation = 880;
            enemyXLocation  = -20;
            enemyYLocation  = Dir.rnd.Next(213, 600);
            enemy2XLocation = Dir.rnd.Next(Dir.rightBoundary - 300, Dir.rightBoundary);
            anchorXLocation = Dir.rnd.Next(Dir.leftBoundary + 100, Dir.rightBoundary - 100);
            anchorYLocation = 175;

            texBackgroundLevel2    = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Sea04.png");
            texPlayer              = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\ship-md.png");
            texEnemy1              = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant1.png");
            texEnemy2              = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant2.png");
            texMissile             = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Torpedo5up.png");
            texMissileSmoke        = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Particle1.png");
            texExplostionAnimation = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\explodeWater1024x64.png");
            texMineExplostion      = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\explode1.png");
            texMouse        = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Mouse.png");
            texAnchor       = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\anchor-th.png");
            texLife         = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\life-preserver-th.png");
            texMine         = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\water_mine.png");
            scoreFont       = Content.Load <SpriteFont>("display");
            helpFont        = Content.Load <SpriteFont>("helpText");
            explostionSound = Content.Load <SoundEffect>("bazooka_fire");
            exLimSound      = new LimitSound(explostionSound, 3);

            backgroundLevel2        = new ImageBackground(texBackgroundLevel2, Color.White, graphicsDevice);
            player                  = new Sprite3(true, texPlayer, playerXLocation, playerYLocation);
            enemy1                  = new Sprite3(true, texEnemy1, enemyXLocation, enemyYLocation);
            enemy2                  = new Sprite3(true, texEnemy2, enemy2XLocation, enemyYLocation);
            explosionAnimation      = new Sprite3(true, texExplostionAnimation, 0, playerYLocation);
            mineExplostionAnimation = new Sprite3(true, texMineExplostion, 0, playerYLocation);
            mine = new Sprite3(true, texMine, 0, 0);
            mine.setHSoffset(new Vector2(296, 313));
            weaponList.addSpriteReuse(mine);
            life = new Sprite3(true, texLife, Dir.rnd.Next(Dir.leftBoundary + 200, Dir.rightBoundary - 200), Dir.rnd.Next(300, 600));
            life.setActiveAndVisible(false);

            for (int i = 1; i < 3; i++)
            {
                anchor = new Sprite3(true, texAnchor, anchorXLocation, anchorYLocation);
                anchor.setWidthHeight(50, 50);
                weaponList.addSpriteReuse(anchor);
            }
            for (int m = 1; m < 6; m++)
            {
                missile = new Sprite3(true, texMissile, playerXLocation, playerYLocation);
                missile.setWidthHeight(missile.getWidth() / 2, missile.getHeight() / 2);
                weaponList.addSpriteReuse(missile);
            }

            player.setColor(Color.Red);

            // Adjusting sprite image sizes to suit my taste
            player.setWidthHeight(210, 64);
            enemy1.setWidthHeight(256, 64);
            enemy2.setWidthHeight(enemy1.getWidth() / 2, 64);
            life.setWidthHeight(48, 48);
            mine.setWidthHeight(40, 45);

            // animation for torpedo explosion
            explosionAnimation.setWidthHeightOfTex(1024, 64);
            explosionAnimation.setXframes(16);
            explosionAnimation.setYframes(1);
            explosionAnimation.setWidthHeight(80, 80);
            for (int moveX = 0; moveX <= 15; moveX++)
            {
                anim[moveX].X = moveX; anim[moveX].Y = 0;
            }
            explosionAnimation.setAnimationSequence(anim, 0, 15, 3);
            explosionAnimation.setAnimFinished(0);
            explosionAnimation.animationStart();

            // animation for mine explostion
            mineExplostionAnimation.setWidthHeightOfTex(1024, 64);
            mineExplostionAnimation.setXframes(16);
            mineExplostionAnimation.setYframes(1);
            mineExplostionAnimation.setWidthHeight(80, 80);
            for (int moveX = 0; moveX <= 15; moveX++)
            {
                mineAnim[moveX].X = moveX; mineAnim[moveX].Y = 0;
            }
            mineExplostionAnimation.setAnimationSequence(mineAnim, 0, 15, 4);
            mineExplostionAnimation.setAnimFinished(0);
            mineExplostionAnimation.animationStart();

            HealthBarAttached h1 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true);

            h1.offset                 = new Vector2(0, -1); // one pixel above the bounding box
            h1.gapOfbar               = 2;
            enemy1.hitPoints          = 10;
            enemy1.maxHitPoints       = 10;
            enemy1.attachedRenderable = h1;

            HealthBarAttached h2 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true);

            h2.offset                 = new Vector2(0, -1); // one pixel above the bounding box
            h2.gapOfbar               = 2;
            enemy2.hitPoints          = 20;
            enemy2.maxHitPoints       = 20;
            enemy2.attachedRenderable = h2;

            HealthBarAttached playerHP = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true);

            playerHP.offset           = new Vector2(0, -1); // one pixel above the bounding box
            playerHP.gapOfbar         = 2;
            player.hitPoints          = 50;
            player.maxHitPoints       = 50;
            player.attachedRenderable = playerHP;

            drawSmoke();
        }
Esempio n. 9
0
        public override void LoadContent()
        {
            enemyList = new SpriteList(20);

            playerXLocation = Dir.rnd.Next(0, 1000);
            playerYLocation = 880;
            enemyXLocation  = -20;
            enemyYLocation  = Dir.rnd.Next(213, 600);
            enemy2XLocation = Dir.rnd.Next(Dir.rightBoundary - 300, Dir.rightBoundary);
            enemy3YLocation = enemyYLocation + Dir.rnd.Next(100, 200);

            // Image Locations
            Dir.texBackground      = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Sea04.png");
            texPlayer              = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\ship-md.png");
            texEnemy1              = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant1.png");
            texEnemy2              = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant2.png");
            texMissile             = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Torpedo5up.png");
            texMissileSmoke        = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Particle1.png");
            texExplostionAnimation = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\explode1.png");

            scoreFont       = Content.Load <SpriteFont>("display");
            helpFont        = Content.Load <SpriteFont>("helpText");
            explostionSound = Content.Load <SoundEffect>("bazooka_fire");
            exLimSound      = new LimitSound(explostionSound, 3);

            // Set Sprites
            Dir.background     = new ImageBackground(Dir.texBackground, Color.White, graphicsDevice);
            player             = new Sprite3(true, texPlayer, playerXLocation, playerYLocation);
            enemy1             = new Sprite3(true, texEnemy1, enemyXLocation, enemyYLocation);
            enemy2             = new Sprite3(true, texEnemy2, enemy2XLocation, enemyYLocation);
            enemy3             = new Sprite3(true, texEnemy1, enemyXLocation, enemy3YLocation);
            missile            = new Sprite3(true, texMissile, playerXLocation, playerYLocation);
            explosionAnimation = new Sprite3(true, texExplostionAnimation, 0, playerYLocation);

            // Adjusting sprite image sizes to suit my taste
            player.setWidthHeight(210, 64);
            enemy1.setWidthHeight(256, 64);
            enemy2.setWidthHeight(enemy1.getWidth() / 2, 64);
            enemy3.setWidthHeight(256, 64);
            missile.setWidthHeight(missile.getWidth() / 2, missile.getHeight() / 2);

            HealthBarAttached h1 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true);

            h1.offset                 = new Vector2(0, -1); // one pixel above the bounding box
            h1.gapOfbar               = 2;
            enemy1.hitPoints          = 10;
            enemy1.maxHitPoints       = 10;
            enemy1.attachedRenderable = h1;

            HealthBarAttached h2 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true);

            h2.offset                 = new Vector2(0, -1); // one pixel above the bounding box
            h2.gapOfbar               = 2;
            enemy2.hitPoints          = 20;
            enemy2.maxHitPoints       = 20;
            enemy2.attachedRenderable = h2;

            HealthBarAttached h3 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true);

            h3.offset                 = new Vector2(0, -1); // one pixel above the bounding box
            h3.gapOfbar               = 2;
            enemy3.hitPoints          = 10;
            enemy3.maxHitPoints       = 10;
            enemy3.attachedRenderable = h3;

            // Add to sprite list
            enemyList.addSpriteReuse(enemy1);
            enemyList.addSpriteReuse(enemy2);
            enemyList.addSpriteReuse(enemy3);

            explosionAnimation.setWidthHeightOfTex(1024, 64);
            explosionAnimation.setXframes(16);
            explosionAnimation.setYframes(1);
            explosionAnimation.setWidthHeight(90, 90);
            for (int moveX = 0; moveX <= 15; moveX++)
            {
                anim[moveX].X = moveX; anim[moveX].Y = 0;
            }
            explosionAnimation.setAnimationSequence(anim, 0, 15, 4);
            explosionAnimation.setAnimFinished(0);
            explosionAnimation.animationStart();

            drawSmoke();
        }