Esempio n. 1
0
        //Creates blood splatter animation when player or enemy gets hit
        public void Blood(float x, float y, bool isHorse)
        {
            Sprite3 blood = new Sprite3(true, texBlood, x - 10, y - 20);

            blood.setYframes(6);
            if (isHorse)
            {
                blood.setWidthHeight(texBlood.Width * 0.2f, texBlood.Height / 6 * 0.2f);
            }
            else
            {
                blood.setWidthHeight(texBlood.Width * 0.1f, texBlood.Height / 6 * 0.1f);
            }
            Vector2[] animBlood = new Vector2[6];
            for (int h = 0; h < animBlood.Length; h++)
            {
                animBlood[h].Y = h;
            }

            blood.setAnimationSequence(animBlood, 0, 5, 5);
            blood.setAnimFinished(2);
            blood.animationStart();

            bloodSplat.addSpriteReuse(blood);
        }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here


            //base initialize calls loadcontent
            base.Initialize();


            random       = new Random();
            playArea     = new Rectangle(lhs, top, rhs - lhs, bot - top);
            spritePlayer = new Sprite3(true, playerTex, 50, SCREEN_HEIGHT / 2 - 50);
            spritePlayer.setWidthHeight(100, 100);
            spritePlayer.setFlip(SpriteEffects.FlipHorizontally);
            //spritePlayer.setBB(0,0,200, 200);



            scrollBack       = new ScrollBackGround(texBackground, texBackground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -1 + playerSpeeeeeed, 2);
            scrollFore       = new ScrollBackGround(texForeground, texForeground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -2 + playerSpeeeeeed, 2);
            textScore        = new TextRenderable("Score : " + score.ToString(), new Vector2(100, 100), spriteFont, Color.Red);
            textStartGame    = new TextRenderable("PRESS ENTER TO START", new Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2), spriteFont, Color.Red);
            particleList     = new SpriteList();
            enemyList        = new SpriteList();
            playerBulletList = new SpriteList();
        }
Esempio n. 3
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. 4
0
        public override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(graphicsDevice);

            // put a font to tell play to press space to start
            //Dir.texBackground = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Press_Space.png");

            float xLocation = Dir.rightBoundary / 2;

            texpressStart = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Press_Space.png");
            texStartSub   = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\navio-hi.png");
            titleFont     = Content.Load <SpriteFont>("display");
            texTitle      = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\title.png");
            introSound    = Content.Load <SoundEffect>("intro_theme");
            intro         = introSound.CreateInstance();

            pressStart = new Sprite3(true, texpressStart, xLocation - 302, Dir.topBoundary + 400);
            startSub   = new Sprite3(true, texStartSub, movingXLocation, Dir.bottomBoundary / 2);
            title      = new Sprite3(true, texTitle, xLocation - 300, 50);

            pressStart.setWidthHeight(pressStart.getWidth() * 2, pressStart.getHeight() * 2);
            title.setWidthHeight((title.getWidth() * 3) / 2, (title.getHeight() * 3) / 2);
            startSub.setWidthHeight(startSub.getWidth() / 2, startSub.getWidth() / 2);

            pressStart.setColor(Color.Aqua);
            startSub.setColor(Color.GreenYellow);
        }
Esempio n. 5
0
        void generateAliens()
        {
            if (numOfTargets >= numOfTargetsMax)
            {
                mgState = 3; return;
            }
            ;

            if (rnd.Next(0, 1000) < genAliensPercent * 10 && numOfTargets < numOfTargetsMax)
            {
                numOfTargets++;
                float   xx = rnd.Next(innerRectangle.X, (int)(innerRectangle.X + innerRectangle.Width - actualTargetSize.X));
                float   yy = innerRectangle.Y - actualTargetSize.Y / 2;
                Sprite3 s  = new Sprite3(true, targetTex, xx, yy);
                s.setWidthHeight(actualTargetSize.X, actualTargetSize.Y);
                s.setBBToTexture();

                //s.setWidthHeightOfTex(1536, 384);
                //s.setXframes(16);
                //s.setYframes(4);
                s.setDeltaSpeed(new Vector2(0, 1));
                //s.setBB(10, 10, 48 - 20, 48 - 20);

                //int frames = 12;
                //Vector2[] anim = new Vector2[frames];
                //for (int i = 0; i < frames; i++)
                //{
                //    anim[i].X = i; anim[i].Y = 0;
                //}
                //s.setAnimationSequence(anim, 0, frames - 1, 3);
                //s.animationStart();
                targets.addSpriteReuse(s);
                AI_xxx = s.getPosX() + s.getWidth() / 2;
            }
        }
Esempio n. 6
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);
        }
        public override void LoadLevel()
        {
            base.LoadLevel();
            Sprite3 newPlatform;

            //DASH LEVEL
            OutOfBounds = new Rectangle(-100, 0, 7000, 1000);


            ////debug
            //newPlatform = new Sprite3(true, texPixel, 0, 700);
            //newPlatform.setWidthHeight(7000, 30);
            //platformList.addSpriteReuse(newPlatform);
            //start platform
            newPlatform = new Sprite3(true, texPixel, 200, 600);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);
            PlayerSpawnPosition = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100);


            newPlatform = new Sprite3(true, texPixel, 3000, 600);
            newPlatform.setWidthHeight(300, 30);
            platformList.addSpriteReuse(newPlatform);
            //make goal on last platform
            goal = new GoalZone(newPlatform);


            if (!isChallengeMode)
            {
                targetSpawnPositions.Add(new Vector2(512, 429));
                targetSpawnPositions.Add(new Vector2(833, 422));
                targetSpawnPositions.Add(new Vector2(1119, 424));
                //targetSpawnPositions.Add(new Vector2(1430, 422));
                targetSpawnPositions.Add(new Vector2(1745, 422));
                //targetSpawnPositions.Add(new Vector2(2065, 422));
                targetSpawnPositions.Add(new Vector2(2378, 422));
                //targetSpawnPositions.Add(new Vector2(2725, 422));
            }
            else
            {
                //ceiling
                newPlatform = new Sprite3(true, texPixel, 0, 400);
                newPlatform.setWidthHeight(7000, 30);
                platformList.addSpriteReuse(newPlatform);


                targetSpawnPositions.Add(new Vector2(512, 429));
                targetSpawnPositions.Add(new Vector2(833, 422));
                targetSpawnPositions.Add(new Vector2(1119, 424));
                targetSpawnPositions.Add(new Vector2(1430, 422));
                targetSpawnPositions.Add(new Vector2(1745, 422));
                targetSpawnPositions.Add(new Vector2(2065, 422));
                targetSpawnPositions.Add(new Vector2(2378, 422));
                targetSpawnPositions.Add(new Vector2(2725, 422));
                targetSpawnPositions.Add(new Vector2(2992, 422));
            }
        }
        public override void LoadLevel()
        {
            base.LoadLevel();

            Sprite3 newPlatform;

            //PIT LEVEL.
            OutOfBounds = new Rectangle(-100, 0, Game1.SCREEN_WIDTH + 100, 1000);
            //ceiling
            newPlatform = new Sprite3(true, texPixel, 0, 0);
            newPlatform.setWidthHeight(2000, 30);
            platformList.addSpriteReuse(newPlatform);
            //start platform
            newPlatform = new Sprite3(true, texPixel, PlayerSpawnPosition.X - player.getWidth(), PlayerSpawnPosition.Y + 100);
            newPlatform.setWidthHeight(150, 30);
            platformList.addSpriteReuse(newPlatform);
            //wall blocking way
            newPlatform = new Sprite3(true, texPixel, 500, 0);
            newPlatform.setWidthHeight(30, 500);
            platformList.addSpriteReuse(newPlatform);
            //goalplatform
            newPlatform = new Sprite3(true, texPixel, 700, PlayerSpawnPosition.Y + 100);
            newPlatform.setWidthHeight(150, 30);
            platformList.addSpriteReuse(newPlatform);

            if (!isChallengeMode)
            {
                //EASY PIT LEVEL
                targetSpawnPositions.Add(new Vector2(368, 175));
                targetSpawnPositions.Add(new Vector2(360, 316));
                targetSpawnPositions.Add(new Vector2(346, 448));
                targetSpawnPositions.Add(new Vector2(337, 594));
                targetSpawnPositions.Add(new Vector2(468, 592));
                targetSpawnPositions.Add(new Vector2(592, 590));
                targetSpawnPositions.Add(new Vector2(587, 479));
                targetSpawnPositions.Add(new Vector2(580, 358));
                targetSpawnPositions.Add(new Vector2(583, 243));
                targetSpawnPositions.Add(new Vector2(590, 149));
            }
            else
            {
                //TAEWOOKS LEVEL
                targetSpawnPositions.Add(new Vector2(736, 459));
                targetSpawnPositions.Add(new Vector2(1039, 574));
                targetSpawnPositions.Add(new Vector2(910, 389));
                targetSpawnPositions.Add(new Vector2(83, 711));
                targetSpawnPositions.Add(new Vector2(509, 599));
                targetSpawnPositions.Add(new Vector2(577, 298));
                targetSpawnPositions.Add(new Vector2(577, 180));
            }
            //make goal on platform
            // goal = new GoalZone(new Vector2(700, PlayerSpawnPosition.Y), 100, 100);
            goal = new GoalZone(newPlatform);
        }
        public override void LoadLevel()
        {
            Sprite3 newPlatform;

            base.LoadLevel();
            OutOfBounds = new Rectangle(-100, 0, 7000, 1000);
            //TUTORIAL START
            newPlatform = new Sprite3(true, texPixel, 0, 700);
            newPlatform.setWidthHeight(800, 30);
            platformList.addSpriteReuse(newPlatform);
            //pit between these two
            newPlatform = new Sprite3(true, texPixel, 1700, 700);
            newPlatform.setWidthHeight(2000, 30);
            platformList.addSpriteReuse(newPlatform);
            //the double jump test. player has to hold A on one or both of the jumps to pass.
            newPlatform = new Sprite3(true, texPixel, 500, 500);
            newPlatform.setWidthHeight(30, 200);
            platformList.addSpriteReuse(newPlatform);
            //tutorial target
            targetSpawnPositions.Add(new Vector2(2051, 507));
            //High wall
            newPlatform = new Sprite3(true, texPixel, 2551, 300);
            newPlatform.setWidthHeight(30, 400);
            platformList.addSpriteReuse(newPlatform);
            //targets to make the high wall
            targetSpawnPositions.Add(new Vector2(2432, 587));
            targetSpawnPositions.Add(new Vector2(2427, 493));
            targetSpawnPositions.Add(new Vector2(2427, 389));
            targetSpawnPositions.Add(new Vector2(2430, 300));
            targetSpawnPositions.Add(new Vector2(2436, 196));
            //-----------
            newPlatform = new Sprite3(true, texPixel, 3000, 700);
            newPlatform.setWidthHeight(800, 30);
            platformList.addSpriteReuse(newPlatform);
            //bigger target pit
            newPlatform = new Sprite3(true, texPixel, 4850, 700);
            newPlatform.setWidthHeight(3000, 30);
            platformList.addSpriteReuse(newPlatform);
            //tutorial target. respawn?
            targetSpawnPositions.Add(new Vector2(4274, 463));
            //checkpoint
            targetSpawnPositions.Add(new Vector2(3527, 627));
            //goalPlatform
            Sprite3 goalPlatform = new Sprite3(true, texPixel, 5150, 700);

            goalPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(goalPlatform);
            goal = new GoalZone(goalPlatform);
            //Wall behind goal
            newPlatform = new Sprite3(true, texPixel, 5350, -10);
            newPlatform.setWidthHeight(800, 900);
            platformList.addSpriteReuse(newPlatform);
        }
Esempio n. 10
0
        public override void LoadContent()
        {
            pauseHelpText  = Content.Load <SpriteFont>("helpText");
            texPauseScreen = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Pause.jpg");  //
            texBack        = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Pause.jpg");  //
            texPause       = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Pause2.jpg"); //

            pauseBackground = new ImageBackground(texBack, Color.White, graphicsDevice);
            pause           = new Sprite3(true, texPause, 444, 30);

            pause.setWidthHeight(pause.getWidth() / 2, pause.getHeight() / 2);
            pause.setColor(Color.Aquamarine);
        }
Esempio n. 11
0
        //Adds bullet to bullet list based on parameters
        public void AddBullet(int x, int y)
        {
            int xOffset = (int)spritePlayer.getWidth();
            int yOffset = (int)spritePlayer.getHeight() / 2;

            //int bulletSpeed = 100;

            Sprite3 bullet = new Sprite3(true, bulletTex, x + xOffset, y + yOffset);

            bullet.setWidthHeight(10, 10);


            playerBulletList.addSpriteReuse(bullet);
        }
        public override void LoadLevel()
        {
            base.LoadLevel();
            Sprite3 newPlatform;

            //PIT LEVEL.
            OutOfBounds = new Rectangle(-100, 0, Game1.SCREEN_WIDTH + 100, 1000);

            newPlatform = new Sprite3(true, texPixel, 200, 600);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);

            PlayerSpawnPosition = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100);



            targetSpawnPositions.Add(new Vector2(135, 79));
            targetSpawnPositions.Add(new Vector2(411, 53));
            targetSpawnPositions.Add(new Vector2(295, 295));
            targetSpawnPositions.Add(new Vector2(270, 145));
            targetSpawnPositions.Add(new Vector2(515, 376));
            targetSpawnPositions.Add(new Vector2(484, 213));
            targetSpawnPositions.Add(new Vector2(123, 461));
            targetSpawnPositions.Add(new Vector2(164, 246));
            targetSpawnPositions.Add(new Vector2(400, 502));
            targetSpawnPositions.Add(new Vector2(399, 368));
            targetSpawnPositions.Add(new Vector2(701, 511));
            targetSpawnPositions.Add(new Vector2(562, 461));
            targetSpawnPositions.Add(new Vector2(642, 261));
            targetSpawnPositions.Add(new Vector2(907, 494));
            targetSpawnPositions.Add(new Vector2(730, 381));
            targetSpawnPositions.Add(new Vector2(628, 93));
            targetSpawnPositions.Add(new Vector2(839, 52));
            targetSpawnPositions.Add(new Vector2(945, 378));
            targetSpawnPositions.Add(new Vector2(819, 201));
            targetSpawnPositions.Add(new Vector2(847, 410));
            targetSpawnPositions.Add(new Vector2(976, 200));
            targetSpawnPositions.Add(new Vector2(1082, 499));
            targetSpawnPositions.Add(new Vector2(1077, 293));

            newPlatform = new Sprite3(true, texPixel, 1100, 150);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);
            //make goal on platform
            // goal = new GoalZone(new Vector2(700, PlayerSpawnPosition.Y), 100, 100);
            goal = new GoalZone(newPlatform);
            player.LoadPlatformsPlayer(platformList);
        }
        public override void LoadLevel()
        {
            base.LoadLevel();
            Sprite3 newPlatform;

            OutOfBounds  = new Rectangle(0, 0, Game1.SCREEN_WIDTH, 1000);
            platformList = new SpriteList();

            newPlatform = new Sprite3(true, texPixel, 200, 700);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);
            targetSpawnPositions = new List <Vector2>();
            PlayerSpawnPosition  = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100);


            newPlatform = new Sprite3(true, texPixel, 700, 150);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);

            if (!isChallengeMode)
            {
                targetSpawnPositions.Add(new Vector2(280, 586));
                targetSpawnPositions.Add(new Vector2(325, 487));
                targetSpawnPositions.Add(new Vector2(367, 394));
                targetSpawnPositions.Add(new Vector2(414, 294));
                targetSpawnPositions.Add(new Vector2(469, 188));
                targetSpawnPositions.Add(new Vector2(526, 82));
            }
            else
            {
                targetSpawnPositions.Add(new Vector2(68, 608));
                targetSpawnPositions.Add(new Vector2(68, 497));
                targetSpawnPositions.Add(new Vector2(67, 399));
                targetSpawnPositions.Add(new Vector2(72, 293));
                targetSpawnPositions.Add(new Vector2(79, 185));
                targetSpawnPositions.Add(new Vector2(78, 90));
            }


            goal = new GoalZone(newPlatform);
            player.LoadPlatformsPlayer(platformList);
        }
        public override void LoadLevel()
        {
            Game1.TimeScore = 0;
            base.LoadLevel();
            Sprite3 newPlatform;

            OutOfBounds = new Rectangle(0, 0, Game1.SCREEN_WIDTH, 1000);


            newPlatform = new Sprite3(true, texPixel, 200, 500);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);

            PlayerSpawnPosition = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100);

            newPlatform = new Sprite3(true, texPixel, 900, 500);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);

            if (!isChallengeMode)
            {
                targetSpawnPositions.Add(new Vector2(380, 362));
                targetSpawnPositions.Add(new Vector2(552, 359));
                targetSpawnPositions.Add(new Vector2(717, 354));
            }
            else
            {
                targetSpawnPositions.Add(new Vector2(74, 396));
                targetSpawnPositions.Add(new Vector2(69, 537));
                targetSpawnPositions.Add(new Vector2(70, 682));
                targetSpawnPositions.Add(new Vector2(272, 675));
                targetSpawnPositions.Add(new Vector2(471, 664));
                targetSpawnPositions.Add(new Vector2(668, 656));
                targetSpawnPositions.Add(new Vector2(850, 654));
                targetSpawnPositions.Add(new Vector2(1018, 647));
                targetSpawnPositions.Add(new Vector2(1158, 650));
                targetSpawnPositions.Add(new Vector2(1144, 545));
                targetSpawnPositions.Add(new Vector2(1144, 420));
            }

            goal = new GoalZone(newPlatform);
        }
Esempio n. 15
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. 16
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. 17
0
        void sizeTheShooter()
        {
            actualShooterSize = new Vector2(shooterSize.X * innerRectangle.Width / baseWidth, shooterSize.Y * innerRectangle.Height / baseHeight);

            shotWidth          = (int)(actualShooterSize.X * 0.1f);
            shotLength         = (int)(actualShooterSize.Y * 0.6f);
            shooterShellOffset = new Vector2(actualShooterSize.X / 2 - shotWidth / 2, 0);
            if (shotWidth < 1)
            {
                shotWidth = 1;
            }
            if (shotLength < 1)
            {
                shotLength = 1;
            }

            float xx = innerRectangle.X + innerRectangle.Width / 2;
            float yy = innerRectangle.Y + innerRectangle.Height - actualShooterSize.Y;

            shooter = new Sprite3(true, shooterTex, xx, yy);
            shooter.setWidthHeight(actualShooterSize.X, actualShooterSize.Y);
            shooter.setBBToTexture();
        }
Esempio n. 18
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. 19
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. 20
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. 21
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        /// This is a mess, please forgive me
        protected override void Update(GameTime gameTime)
        {
            //Console.WriteLine(enemies.count());
            curPos = horse.getPos();
            bool keyDown = false;

            switch (level)
            {
            case 1:
                horse.setWidthHeight(1568 / 8 * 0.3f, texHorseRun.Height * 0.3f);
                k = Keyboard.GetState();
                if (!started)
                {
                    started = true;
                    StartMovement(8);
                }

                if (k.IsKeyDown(Keys.Down))
                {
                    keyDown = true;
                    horse.setPosY(horse.getPosY() + movementSpeed - 2);
                }

                if (k.IsKeyDown(Keys.Up))
                {
                    keyDown = true;
                    horse.setPosY(horse.getPosY() - movementSpeed + 2);
                }

                if (k.IsKeyDown(Keys.Left))
                {
                    keyDown = true;
                    horse.setFlip(SpriteEffects.FlipHorizontally);
                    horse.setPosX(horse.getPosX() - movementSpeed + 2);
                }

                if (k.IsKeyDown(Keys.Right))
                {
                    keyDown = true;
                    horse.setFlip(SpriteEffects.None);
                    horse.setPosX(horse.getPosX() + movementSpeed - 2);
                }
                if (!keyDown)
                {
                    horse.setAnimationSequence(anim, 0, 7, 0);
                }
                else
                {
                    horse.setAnimationSequence(anim, 0, 7, 8);
                }
                //387 330
                if (curPos.X >= -155 && curPos.X <= -75 && curPos.Y >= 330 && curPos.Y <= 387)
                {
                    horse.setPos(xx, yy);
                    started = false;
                    horse.setFlip(SpriteEffects.None);
                    level = 0;
                }

                horseRun.animationTick(gameTime);
                mainCamera.Follow(horse);

                break;

            default:
                if (!started)
                {
                    if (k.IsKeyDown(Keys.D1) || k.IsKeyDown(Keys.NumPad1))
                    {
                        difficulty = 1;
                    }
                    else if (k.IsKeyDown(Keys.D2) || k.IsKeyDown(Keys.NumPad2))
                    {
                        difficulty = 2;
                    }
                    else if (k.IsKeyDown(Keys.D3) || k.IsKeyDown(Keys.NumPad3))
                    {
                        difficulty = 3;
                    }
                }
                switch (difficulty)
                {
                case 1:
                    difficultyOffset = 1;
                    break;

                case 2:
                    difficultyOffset = 0.5f;
                    break;

                case 3:
                    difficultyOffset = 0.1f;
                    break;

                default:
                    break;
                }
                horse.setWidthHeight(1568 / 8 * 0.5f, texHorseRun.Height * 0.5f);
                //This timer makes basic instructions disappear after 3 seconds
                if (textFadeTimer < 3 && started)
                {
                    textFadeTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                if (started)
                {
                    enemySpawnTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }

                if (enemySpawnTimer > difficultyOffset)
                {
                    enemySpawnTimer = 0;
                    LoadEnemies();
                }

                //Escape key exits game
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    Exit();
                }

                //Keyboard current and previous state
                prevK = k;
                k     = Keyboard.GetState();

                //Begin all game functionality essentially
                if (k.IsKeyDown(Keys.Enter) && !started)
                {
                    started = true;
                    StartMovement(8);
                }

                if (started)
                {
                    //Bounding box activation key
                    if (k.IsKeyDown(Keys.B) && prevK.IsKeyUp(Keys.B))
                    {
                        showbb = !showbb;
                    }

                    //Game over is a bool that is used to ensure the player can't move horse after it is dead, causes errors otherwise
                    if (!gameOver)
                    {
                        //Player movement down
                        if (k.IsKeyDown(Keys.Down))
                        {
                            if (horseRun.getSprite(0).getPosY() < bot - horse.getHeight())
                            {
                                horseRun.getSprite(0).setPosY(horseRun.getSprite(0).getPosY() + movementSpeed);
                            }
                        }
                        //Player movement up
                        if (k.IsKeyDown(Keys.Up))
                        {
                            if (horseRun.getSprite(0).getPosY() > top)
                            {
                                horseRun.getSprite(0).setPosY(horseRun.getSprite(0).getPosY() - movementSpeed);
                            }
                        }
                    }

                    for (int e = 0; e < enemies.count(); e++)
                    {
                        if (enemies[e].getVisible())
                        {
                            enemies[e].setPosX(enemies[e].getPosX() - enemyMovementSpeed);
                        }
                        if (enemies[e].getPosX() < 0 - texEnemy.Width)
                        {
                            enemies[e].setVisible(false);
                        }
                    }

                    //Collision detection, arrow to enemy
                    for (int ea = 0; ea < quiver.count(); ea++)
                    {
                        int ac = enemies.collisionWithRect(quiver[ea].getBoundingBoxAA());
                        if (ac != -1)
                        {
                            score++;
                            Blood(enemies.getSprite(ac).getPosX(), enemies.getSprite(ac).getPosY(), false);
                            enemies.getSprite(ac).setVisible(false);
                            quiver[ea].setVisible(false);
                            quiver[ea].setPos(new Vector2(0, 0));
                            //LoadEnemies();
                        }
                    }


                    //Allow player to increase or decrease speed
                    if (Keyboard.GetState().IsKeyDown(Keys.Right))
                    {
                        enemyMovementSpeed = fastEnemy;
                        horse.setAnimationSequence(anim, 0, 7, fastPlayer);
                    }
                    else if (Keyboard.GetState().IsKeyDown(Keys.Left))
                    {
                        enemyMovementSpeed = slowEnemy;
                        horse.setAnimationSequence(anim, 0, 7, slowPlayer);
                    }
                    else if (started)
                    {
                        enemyMovementSpeed = normalEnemy;
                        horse.setAnimationSequence(anim, 0, 7, normalPlayer);
                    }

                    //Scrolling background functionality
                    if (scrolling1.rectangle.X + scrolling1.texture.Width <= 0)
                    {
                        scrolling1.rectangle.X = scrolling2.rectangle.X + scrolling2.texture.Width;
                    }
                    if (scrolling2.rectangle.X + scrolling2.texture.Width <= 0)
                    {
                        scrolling2.rectangle.X = scrolling1.rectangle.X + scrolling1.texture.Width;
                    }
                    scrolling1.Update();
                    scrolling2.Update();

                    //Game over is a bool that is used to ensure the player can't move horse after it is dead, causes errors otherwise
                    if (!gameOver)
                    {
                        //Collision detection, enemy to player
                        int rc = enemies.collisionWithRect(horse.getBoundingBoxAA());
                        if (rc != -1)
                        {
                            Blood(horse.getPosX(), horse.getPosY(), true);
                            movementSpeed      = 0;
                            enemyMovementSpeed = 0;
                            scrolling1.speed   = 0;
                            scrolling2.speed   = 0;
                            for (int i = 0; i < horseRun.count(); i++)
                            {
                                horseRun.deleteSprite(i);
                            }
                            gameOver = true;
                        }
                    }

                    //Shooting arrow functionality
                    if (Keyboard.GetState().IsKeyDown(Keys.Space) && !arrowShot)
                    {
                        Arrow();
                        arrowShot = true;
                    }
                    for (int a = 0; a < quiver.count(); a++)
                    {
                        if (quiver[a].getVisible())
                        {
                            quiver[a].savePosition();
                            quiver[a].moveByDeltaXY();
                        }
                        if (quiver[a].getPosX() > 800)
                        {
                            quiver[a].setVisible(false);
                        }
                    }
                    if (arrowShot)
                    {
                        arrowTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                    if (arrowTimer > 0.5f)
                    {
                        arrowTimer = 0;
                        arrowShot  = false;
                    }
                }

                //Animation ticks for anything that is being animated
                horseRun.animationTick(gameTime);
                enemies.animationTick(gameTime);
                bloodSplat.animationTick(gameTime);

                if (gameOver)
                {
                    deathTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                break;
            }
            base.Update(gameTime);
        }
Esempio n. 22
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. 23
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();
        }