Example #1
1
        /// <summary>
        /// Create a new game screen. Should be done every time there is a new game.
        /// </summary>
        /// <param name="theScreenEvent"></param>
        /// <param name="contentManager"></param>
        public GameScreen(EventHandler theScreenEvent,ContentManager contentManager)
            : base(theScreenEvent)
        {
            bScoreWasAdded = false;

            this.contentManager = contentManager;
            dlDoubleJumpTimer = new DanLabel(1150, 20, 100, 50);

            //Init our intrepid hero
            csHero = new ControlledSprite();

            bg = new LayeredBackground();

            djeJumpEffect = new DoubleJumpEffect();

            altimeter = new Altimeter(); // Make a camera for the screen with an altimeter
            cCamera = new Camera(50, 100, 600, 520, altimeter);

            blocks = new List<Sprite>();
            Sprite sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);

            // REVIST Set up the Arcing Block Manager with the difficulty
            arcingBlockManager = new ArcingBlockManager(cCamera, blocks, contentManager, 500, 300, 150, "Sprites/block2");
        }
Example #2
0
        /// <summary>
        /// Create a new high score screen.
        /// </summary>
        /// <param name="theScreenEvent"></param>
        /// <param name="theContent"></param>
        /// <param name="myConfig">The high scores are stored in the config object.</param>
        public HighScoreScreen(EventHandler theScreenEvent, ContentManager theContent)
            : base(theScreenEvent)
        {
            lbBackground = new LayeredBackground();

            dlHighscoreText = new DanLabel(600, 100, 200, 400);
        }
Example #3
0
 /// <summary>
 /// Create a new main menu screen.
 /// </summary>
 /// <param name="theScreenEvent"></param>
 public MenuScreen(EventHandler theScreenEvent)
     : base(theScreenEvent)
 {
     //Load the background texture for the screen
     lbBackground = new LayeredBackground();
     spTitle = new Sprite();
     mMenu = new Menu(new Vector2(300, 250));
 }
Example #4
0
        /// <summary>
        /// Update the Camera
        /// </summary>
        /// <param name="theGameTime">The Game Time</param>
        /// <param name="blocks">The list of blocks that are affected by the camera.</param>
        /// <param name="csHero">The hero object.</param>
        /// <param name="bg">The current background</param>
        public void Update(GameTime theGameTime, List<Sprite> blocks, ControlledSprite csHero, LayeredBackground bg)
        {
            // Whether or not the hero is outside the camera bounds
            if ((csHero.Position.Y < rectCamera.Y && (csHero.mSpeed.Y < 0 || csHero.spLinkBlock.Velocity.Y < 0))
                || (csHero.Position.Y + csHero.Size.Height > rectCamera.Y + rectCamera.Height && (csHero.mSpeed.Y > 0 || csHero.spLinkBlock.Velocity.Y > 0)))
            {
                float goalDiffShift = 0;//how much it wants to compensate
                if (csHero.Position.Y <= rectCamera.Y && (csHero.mSpeed.Y < 0 || csHero.spLinkBlock.Velocity.Y < 0))//pushing cam up
                {
                    goalDiffShift = (csHero.Position.Y - rectCamera.Y);//should be neg
                    fallenAmount = 0;
                }
                else if (csHero.Position.Y + csHero.Size.Height > rectCamera.Y + rectCamera.Height && (csHero.mSpeed.Y > 0 || csHero.spLinkBlock.Velocity.Y > 0))//dragging cam down
                {
                    goalDiffShift = ((csHero.Position.Y + csHero.Size.Height) - (rectCamera.Y + rectCamera.Height));//should be pos
                    fallenAmount += goalDiffShift; // Add up how much the hero has fallen.
                }

                // Check to see if the game is over
                if (fallenAmount > 1000)
                {
                    csHero.IsDead = true;
                }

                float fShiftAmount = 0; // The amount of the hero's motion hidden by the camera movement

                // If the hero is surfing a block we must also factor in the blocks speed to know how much to move
                if (csHero.bLinked)
                    fShiftAmount = (csHero.spLinkBlock.Velocity.Y * (float)theGameTime.ElapsedGameTime.TotalSeconds)
                        + (csHero.mSpeed.Y * (float)theGameTime.ElapsedGameTime.TotalSeconds);

                else // Otherwise just use the hero's speed
                    fShiftAmount = csHero.mSpeed.Y * (float)theGameTime.ElapsedGameTime.TotalSeconds;

                if (fShiftAmount > 0)
                    fShiftAmount = Math.Min(fShiftAmount, goalDiffShift);
                else
                    fShiftAmount = Math.Max(fShiftAmount, goalDiffShift);

                csHero.Position.Y -= fShiftAmount; // Slide hero back so he doesn't move

                // Update altimeter based on camera
                altimeter.UpdateShift(fShiftAmount);

                foreach (Sprite block in blocks) // Move everyone relative to the hero.
                        block.Position.Y -= fShiftAmount;

                // Shift Backgrounds
                // Divided by i so ones in back move slower
                for (int i = 0; i < bg.layers.Count; i++)
                {
                        foreach (Sprite sp in bg.layers[i].Grid)
                            sp.Position.Y -= fShiftAmount / (i + 3);

                    bg.UpdateVertical(theGameTime);
                }
            }
        }
Example #5
0
 /// <summary>
 /// Create a new options menu.
 /// </summary>
 /// <param name="theScreenEvent"></param>
 /// <param name="graphics"></param>
 public OptionsScreen(EventHandler theScreenEvent,GraphicsDeviceManager graphics)
     : base(theScreenEvent)
 {
     //Load the background texture for the screen
     this.graphics = graphics;
     lbBackground = new LayeredBackground();
     mMainMenu = new Menu(new Vector2(50, 100));
     mMusicMenu = new Menu(new Vector2(250, 100), mMainMenu, new EventHandler(BackOutEvent));
     mSFXMenu = new Menu (new Vector2(350, 100), mMainMenu, new EventHandler(BackOutEvent));
     mHeroMenu = new Menu(new Vector2(450, 100), mMainMenu, new EventHandler(BackOutEvent));
     mResolutionMenu = new Menu(new Vector2(250, 100), mMainMenu, new EventHandler(BackOutEvent));
 }
        /// <summary>
        /// Make a new progression given the background, the altimeter, and what pictures 
        /// to swap in at what heights.
        /// </summary>
        public BackgroundProgression(LayeredBackground theBg, Altimeter theAltimeter, string[] theBGAssets,
            string[] theLayer1Assets, string[] theLayer2Assets, int[] theHeights)
        {
            bg = theBg;
            altimeter = theAltimeter;

            bgAssets = theBGAssets;
            layer1Assets = theLayer1Assets;
            layer2Assets = theLayer2Assets;

            heights = theHeights;

            bCheckPoints = new bool[heights.Length];

            for (int i = 0; i < heights.Length; i++)
                bCheckPoints[i] = false;
        }