Example #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);

            // TODO: use this.Content to load your game content here
            startScene = new StartScene(this, spriteBatch);
            Components.Add(startScene);

            helpScene = new HelpScene(this, spriteBatch, graphics);
            Components.Add(helpScene);

            howToScene = new HowToScene(this, spriteBatch);
            Components.Add(howToScene);

            actionScene = new ActionScene(this, spriteBatch);
            Components.Add(actionScene);

            highScoreScene = new HighScoreScene(this, spriteBatch, graphics);
            Components.Add(highScoreScene);

            aboutScene = new AboutScene(this, spriteBatch);
            Components.Add(aboutScene);

            this.startSound  = this.Content.Load <SoundEffect>("startSceneSound3").CreateInstance();
            this.actionSound = this.Content.Load <SoundEffect>("startOrActionSound").CreateInstance();

            startScene.show();
        }
Example #2
0
        /// <summary>
        /// main constructor of this class
        /// </summary>
        /// <param name="game">Provides basic graphics device initialization, game logic, and rendering code.</param>
        /// <param name="spriteBatch">Enables a group of sprites to be drawn using the same settings</param>
        /// <param name="frogTex">texture of normal frog image</param>
        /// <param name="frogGoal">texture of frog image which is goaled in</param>
        /// <param name="frogDeath">texture of frog image which is dying</param>
        /// <param name="frogSkeleton">texture of frog image which is dead</param>
        /// <param name="actionScene">the scene which is include in</param>
        /// <param name="jumpSound">jump sound</param>
        /// <param name="deadSound">dead sound</param>
        public Frog(Game game,
                    SpriteBatch spriteBatch,
                    Texture2D frogTex,
                    Texture2D frogGoal,
                    Texture2D frogDeath,
                    Texture2D frogSkeleton,
                    ActionScene actionScene,
                    SoundEffect jumpSound,
                    SoundEffect deadSound) : base(game)
        {
            // TODO: Construct any child components here
            this.spriteBatch         = spriteBatch;
            this.frogTex             = frogTex;
            this.frogGoal            = frogGoal;
            this.frogDeath           = frogDeath;
            this.frogSkeleton        = frogSkeleton;
            this.actionScene         = actionScene;
            this.jumpSound           = jumpSound;
            this.deadSound           = deadSound;
            jumpSoundInst            = deadSound.CreateInstance();
            this.arrivalSound        = game.Content.Load <SoundEffect>("arrivalSound");
            this.stageClearSoundInst = game.Content.Load <SoundEffect>("nextStageSound").CreateInstance();

            LOW_LIMIT    = (int)(ActionScene.UNIT * 14.5);
            initPosition = new Vector2(ActionScene.UNIT * 7,
                                       LOW_LIMIT);
            position     = initPosition;
            direction    = -1;
            currentFrame = -1;
            // frames for jumping animation
            frames = new List <Rectangle>(5);
            int moveDis = 48;

            for (int i = 0; i < 5; i++)
            {
                frames.Add(new Rectangle(areaX, 0, 48, 48));
                if (areaX == 0 || areaX == 96)
                {
                    moveDis *= -1;
                }

                areaX += moveDis;
            }

            // frames for dying animation
            frames3Cut = new List <Rectangle>(3);
            moveDis    = 48;
            for (int i = 0; i < 3; i++)
            {
                frames3Cut.Add(new Rectangle(i * moveDis, 0, 48, 48));
            }
        }