Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            LineBatch.init(GraphicsDevice);
            texBack   = Util.texFromFile(GraphicsDevice, dir + "back3.png");    //***
            texpaddle = Util.texFromFile(GraphicsDevice, dir + "red64x32.png"); //***
            texBall   = Util.texFromFile(GraphicsDevice, dir + "ball2.png");    //***
            texBlock1 = Util.texFromFile(GraphicsDevice, dir + "white64x32.png");
            paddle    = new Sprite3(true, texpaddle, xx, yy);
            paddle.setBBToTexture();
            ball = new Sprite3(true, texBall, xx, yy);
            ball.setBBandHSFractionOfTexCentered(0.7f);
            sl = new SpriteList();

            back1    = new ImageBackground(texBack, Color.White, GraphicsDevice);
            playArea = new Rectangle(lhs, top, rhs - lhs, bot - top); // width and height
            for (int y = 0; y < 5; y++)
            {
                for (int x = 0; x < 4; x++)
                {
                    Sprite3 s = new Sprite3(true, texBlock1, x * 68 + playArea.X + blocksOffsetX, y * 36 + playArea.Y + blocksOffsetY);
                    s.hitPoints = 1;
                    if (y == 0)
                    {
                        s.hitPoints = 2;
                        s.setColor(Color.LightBlue);
                    }

                    sl.addSpriteReuse(s);
                }
            }
            // TODO: use this.Content to load your game content here
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            LineBatch.init(GraphicsDevice);
            // TODO: use this.Content to load your game content here
            texBack   = Util.texFromFile(GraphicsDevice, dir + "ricefield.png");
            texpaddle = Util.texFromFile(GraphicsDevice, dir + "slime.png");
            texBall   = Util.texFromFile(GraphicsDevice, dir + "slime_slice.png"); //***
            texEnemy  = Util.texFromFile(GraphicsDevice, dir + "ghost.png");
            texGrass1 = Util.texFromFile(GraphicsDevice, dir + "grass1.png");
            texBoom   = Util.texFromFile(GraphicsDevice, dir + "Boom3.png");
            font      = Content.Load <SpriteFont>("incoming");

            paddle = new Sprite3(true, texpaddle, lhs, yy);
            paddle.setBBToTexture();

            enemyList = new SpriteList();
            ballList  = new SpriteList();
            booms     = new SpriteList();

            back1      = new ScrollBackGround(texBack, texBack.Bounds, new Rectangle(0, 0, rhs, 380), -1, 2);
            grass1     = new ScrollBackGround(texGrass1, texGrass1.Bounds, new Rectangle(0, bot - (texGrass1.Height + 30), rhs, bot / 2), -1, 2);
            playArea   = new Rectangle(lhs, top, rhs, bot - 10);
            enemyYY    = new Random();
            enemySpeed = new Random();
        }
Ejemplo n.º 4
0
 // Basic Sprite Constructor
 public SpriteActor(Texture2D tex, Vector2 position, Vector2 velocity)
 {
     spriteSize    = new Vector2(tex.Width, tex.Height);
     this.position = position;
     this.velocity = velocity;
     sprite        = new Sprite3(true, tex, position.X - tex.Width, position.Y - tex.Height);
     sprite.setHSoffset(new Vector2(spriteSize.X / 2, spriteSize.Y / 2));
     sprite.setBBToTexture();
 }
Ejemplo n.º 5
0
        public void NewEnemy(float x, float y)
        {
            Sprite3 enemy = new Sprite3(true, texEnemy, x, (float)enemyYY.NextDouble() * y);

            enemy.setWidth(texEnemy.Width * 0.7f);
            enemy.setHeight(texEnemy.Height * 0.7f);
            enemy.setBBToTexture();
            enemy.hitPoints = 3;

            enemy.setDeltaSpeed(new Vector2((float)enemySpeed.NextDouble() * -10, 0));
            enemyList.addSpriteReuse(enemy);
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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();
        }