public DebugScreen(ContentManager cm, GraphicsDeviceManager gdm, SpriteBatch sb, Color sColor) : base(cm, gdm, sb)
        {
            //configures default map
            //TO DO: fix tile map to be instan
            map = new TileMap(cm, gdm, sb, new Vector2(160, 45), new Vector2(16, 16));

            playerOneCamera = new Camera(cm, gdm, sb, new Vector2(0, 0), graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width, graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Height);
            //playerTwoCamera = new Camera(cm, gdm, sb, new Vector2(0, 0), graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width / 2, graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Height);
            //playerTwoCamera.screenPosition = new Vector2(graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width / 2, 0);

            screenColor = sColor;

            playerOne = new Player(cm, sb, gdm);
            //playerTwo = new Player(cm, sb, gdm);
            //playerTwo.currentWorldPosition = playerTwoCamera.worldPosition;

            platformOne = new TiledPlatform(cm, sb, gdm, true, true, true, true);
            platformOne.platformSize = new Vector2(20, 5);
            platformOne.position     = new Vector2(map.getTileMapWidthInPixels / 2 - platformOne.platformWidth / 2, map.getTileMapHeightInPixels - platformOne.platformHeight);

            hurdleOne = new Hurdle(cm, gdm, sb);
            hurdleOne.worldPosition = new Vector2(map.getTileMapWidthInPixels / 4, map.getTileMapHeightInPixels - hurdleOne.height);

            hurdleTwo = new Hurdle(cm, gdm, sb);
            hurdleTwo.worldPosition = new Vector2(map.getTileMapWidthInPixels / 2 - hurdleTwo.width / 2, map.getTileMapHeightInPixels - platformOne.platformHeight - hurdleTwo.height);

            momentumButtonOne = new MomentumActionButton(cm, gdm, sb, new Vector2(0, 25));
            momentumButtonOne.worldPosition = new Vector2(map.getTileMapWidthInPixels / 2 - momentumButtonOne.width / 2, platformOne.position.Y - 40);

            gravity = new Vector2(0, 9);
        }
示例#2
0
        public Player(ContentManager cm, SpriteBatch sb, GraphicsDeviceManager gdm)
        {
            //configures the image sheet associated with the player
            playerImageSheet = new AnimatedImage(cm, sb, gdm.GraphicsDevice, "PlayerImages/PlayerPlaceholderRefined", new Vector2(1372, 469), new Vector2(18, 5));
            playerImageSheet.frameTimeLimit = 8;
            playerImageSheet.Initialize();
            playerImageSheet.setFrameConfiguration(0, 0, 1);
            //playerImageSheet.isAnimating = false;

            boundingRectangleColor = cm.Load<Texture2D>("CollisionColor");

            //sets the references to the spritebatch and content manager so this class can define items in the content pipeline and draw to the same area
            sbReference = sb;
            cmReference = cm;
            gdmReference = gdm;

            //environment variables
            previousWorldPosition = Vector2.Zero;
            currentWorldPosition = Vector2.Zero;
            velocity = new Vector2(8, 25);
            momentum = new Vector2(0,0);

            movingLeft = false;
            movingRight = false;
            movingUp = false;
            movingDown = false;

            standing = true;

            isJumping = false;
            isFalling = false;
            isFallingFromGravity = false;
            isDashing = false;
            exhaustedDash = false;

            jumpTimer = 0;
            jumpTimerMax = 20;

            dashTimer = 0;
            dashTimerMax = 10;

            currentActionHurdleReference = null;
            actionButtonBeingPressed = false;
            actionStateIsActive = false;
            hurdleActionStateActive = false;
            upTheHurdle = false;
            overTheHurdle = false;
            hurdleTimer = 0;
            hurdleTimerMax = 10;
            hurdleDistance = Vector2.Zero;

            facingLeft = false;
            facingRight = true;

            playerCollisionOccurred = false;
            collisionOnPlayerLeft = false;
            collisionOnPlayerRight = false;
            collisionOnPlayerTop = false;
            collisionOnPlayerBottom = false;
        }
        public RegalFallsDeprecatedOne(ContentManager cm, GraphicsDeviceManager gdm, SpriteBatch sb, ImageLibrary iLibrary, Player pOne) : base(cm, gdm, sb)
        {
            cmReference  = cm;
            gdmReference = gdm;
            sbReference  = sb;

            imageLibrary = iLibrary;

            parallaxBackgrounds = new List <ParallaxBackground>();

            platforms         = new List <Platform>();
            platformsToRemove = new List <Platform>();

            slopedPlatforms = new List <SlopedPlatform>();

            springs = new List <Spring>();

            worldTreasure         = new List <Treasure>();
            worldTreasureToRemove = new List <Treasure>();

            //System.Diagnostics.Debug.WriteLine(testPlatform.platformSlope.getSlope());

            //configures default map
            map = new TileMap(cm, gdm, sb, new Vector2(500, 400), new Vector2(16, 16));
            //----------------------------------------------------------Start Map Configuration----------------------------------------
            int tileTrackerX = 0;
            int tileTrackerY = 0;

            //iterates through row by column and initializes based on some arbitrary distinctions
            while (tileTrackerY < map.tileMapHeight)
            {
                while (tileTrackerX < map.tileMapWidth)
                {
                    /*
                     * if (tileTrackerX > map.tileMapWidth / 2)
                     * {
                     *  //bottom right
                     *  if (tileTrackerY > map.tileMapHeight / 2)
                     *  {
                     *      map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(16, 16), new Vector2(1, 1), imageLibrary.basicGreenTile, false, false, false, false);
                     *  }
                     *  //bottom left
                     *  else
                     *  {
                     *      map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(16, 16), new Vector2(1, 1), imageLibrary.basicOrangeTile, false, false, false, false);
                     *  }
                     * }
                     * //top
                     * else
                     * {
                     *  //top right
                     *  if (tileTrackerY > map.tileMapHeight / 2)
                     *  {
                     *      map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(16, 16), new Vector2(1, 1), imageLibrary.basicYellowTile , false, false, false, false);
                     *  }
                     *  //top left
                     *  else
                     *  {
                     *      map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(16, 16), new Vector2(1, 1), imageLibrary.basicRedTile, false, false, false, false);
                     *  }
                     * }
                     */
                    map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(16, 16), new Vector2(1, 1), imageLibrary.basicBlueTile, false, false, false, false);
                    map.tilePositionX += map.defaultTileWidth;
                    tileTrackerX++;
                }
                map.tilePositionX  = 0;
                tileTrackerX       = 0;
                map.tilePositionY += map.defaultTileHeight;
                tileTrackerY++;
            }
            //----------------------------------------------------------End Map Configuration----------------------------------------
            playerOneCamera = new Camera(cmReference, gdmReference, sbReference, new Vector2(0, 0), gdmReference.GraphicsDevice.Viewport.TitleSafeArea.Width, gdmReference.GraphicsDevice.Viewport.TitleSafeArea.Height);
            //playerTwoCamera = new Camera(cm, gdm, sb, new Vector2(0, 0), graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width / 2, graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Height);
            //playerTwoCamera.screenPosition = new Vector2(graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width / 2, 0);

            playerOne = pOne;
            playerOne.previousWorldPosition = new Vector2(0, 0);
            playerOne.currentWorldPosition  = new Vector2(0, 0);

            //playerTwo = new playerOne(cm, sb, gdm);
            //playerTwo.currentWorldPosition = playerTwoCamera.worldPosition;

            //Configures the lists
            configureParallaxBackgrounds();
            configureWorldPlatforms();
            configureWorldSlopePlatforms();
            configureWorldSprings();
            configureWorldTreasure();

            hurdleOne = new Hurdle(cmReference, gdmReference, sbReference, (new Vector2(4288, 1280 - hurdleOne.height)));

            hurdleTwo = new Hurdle(cmReference, gdmReference, sbReference, (new Vector2(map.getTileMapWidthInPixels / 2 - 400, map.getTileMapHeightInPixels - hurdleTwo.height)));

            testRope = new SwingRope(cmReference, gdmReference, sbReference, new Vector2(2304, 896), 200);

            testLadder = new Ladder(cmReference, gdmReference, sbReference, imageLibrary, new Vector2(2944 - playerOne.width, 1280), new Vector2(playerOne.width, 500));

            gravity = new Vector2(0, 9);
        }
        public RegalFalls(ContentManager cm, GraphicsDeviceManager gdm, SpriteBatch sb, Color sColor) : base(cm, gdm, sb)
        {
            //configures default map
            map = new TileMap(cm, gdm, sb, new Vector2(160, 45), new Vector2(16, 16));
            //----------------------------------------------------------Start Map Configuration----------------------------------------
            int tileTrackerX = 0;
            int tileTrackerY = 0;

            //iterates through row by column and initializes based on some arbitrary distinctions
            while (tileTrackerY < map.tileMapHeight)
            {
                while (tileTrackerX < map.tileMapWidth)
                {
                    /*
                     * if (tileTrackerX == map.tileMapWidth / 2)
                     * {
                     *  map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(80, 16), new Vector2(5, 1), "TileMapImages/AltBasicTileSet", true, true, false, false);
                     *  map.tiles[tileTrackerX, tileTrackerY].isCollidable = true;
                     *  map.tiles[tileTrackerX, tileTrackerY].baseTileImage.setFrameConfiguration(4, 4, 4);
                     * }
                     * else if (tileTrackerY == map.tileMapHeight / 2)
                     * {
                     *  map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(80, 16), new Vector2(5, 1), "TileMapImages/AltBasicTileSet", false, false, true, true);
                     *  map.tiles[tileTrackerX, tileTrackerY].isCollidable = true;
                     *  map.tiles[tileTrackerX, tileTrackerY].baseTileImage.setFrameConfiguration(4, 4, 4);
                     * }*/
                    //else {
                    map.tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(map.tilePositionX, map.tilePositionY), new Vector2(80, 16), new Vector2(5, 1), "TileMapImages/AltBasicTileSet", false, false, false, false);

                    //bottom
                    if (tileTrackerX > map.tileMapWidth / 2)
                    {
                        //bottom right
                        if (tileTrackerY > map.tileMapHeight / 2)
                        {
                            map.tiles[tileTrackerX, tileTrackerY].baseTileImage.setFrameConfiguration(3, 3, 3);
                        }
                        //bottom left
                        else
                        {
                            map.tiles[tileTrackerX, tileTrackerY].baseTileImage.setFrameConfiguration(2, 2, 2);
                        }
                    }
                    //top
                    else
                    {
                        //top right
                        if (tileTrackerY > map.tileMapHeight / 2)
                        {
                            map.tiles[tileTrackerX, tileTrackerY].baseTileImage.setFrameConfiguration(1, 1, 1);
                        }
                        //top left
                        else
                        {
                            map.tiles[tileTrackerX, tileTrackerY].baseTileImage.setFrameConfiguration(0, 0, 0);
                        }
                    }
                    //}
                    //tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(tilePositionX, tilePositionY), new Vector2(80, 16), new Vector2(5, 1), "TileMapImages/BasicTileSet");

                    //tiles[tileTrackerX, tileTrackerY] = new BackgroundTile(cm, gdm, sb, new Vector2(tilePositionX, tilePositionY), imageLibrary.basicTileSet);
                    map.tilePositionX += map.defaultTileWidth;

                    tileTrackerX++;
                }
                map.tilePositionX  = 0;
                tileTrackerX       = 0;
                map.tilePositionY += map.defaultTileHeight;
                tileTrackerY++;
            }
            //----------------------------------------------------------End Map Configuration----------------------------------------
            playerOneCamera = new Camera(cm, gdm, sb, new Vector2(0, 0), graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width, graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Height);
            //playerTwoCamera = new Camera(cm, gdm, sb, new Vector2(0, 0), graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width / 2, graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Height);
            //playerTwoCamera.screenPosition = new Vector2(graphicsDeviceManagerReference.GraphicsDevice.Viewport.TitleSafeArea.Width / 2, 0);

            screenColor = sColor;

            playerOne = new Player(cm, sb, gdm);
            playerOne.previousWorldPosition = new Vector2(0, map.getTileMapHeightInPixels - playerOne.height);
            playerOne.currentWorldPosition  = new Vector2(0, map.getTileMapHeightInPixels - playerOne.height);
            //playerTwo = new Player(cm, sb, gdm);
            //playerTwo.currentWorldPosition = playerTwoCamera.worldPosition;

            platformOne = new TiledPlatform(cm, sb, gdm, true, true, false, false);
            platformOne.platformSize = new Vector2(5, 5);
            platformOne.position     = new Vector2(map.getTileMapWidthInPixels / 2 - platformOne.platformWidth / 2, map.getTileMapHeightInPixels - platformOne.platformHeight);

            platformTwo = new TiledPlatform(cm, sb, gdm, true, true, false, false);
            platformTwo.platformSize = new Vector2(5, 5);
            platformTwo.position     = new Vector2(map.getTileMapWidthInPixels / 2 - platformOne.platformWidth / 2, map.getTileMapHeightInPixels - platformOne.platformHeight - platformTwo.platformHeight);

            platformThree = new TiledPlatform(cm, sb, gdm, false, false, true, false);
            platformThree.platformSize = new Vector2(5, 5);
            platformThree.position     = new Vector2(map.getTileMapWidthInPixels / 2 - platformOne.platformWidth / 2, map.getTileMapHeightInPixels - platformOne.platformHeight - platformTwo.platformHeight - platformThree.platformHeight);

            platformFour = new TiledPlatform(cm, sb, gdm, true, false, true, true);
            platformFour.platformSize = new Vector2(5, 5);
            platformFour.position     = new Vector2(map.getTileMapWidthInPixels / 2 - platformOne.platformWidth / 2 - platformThree.platformWidth, map.getTileMapHeightInPixels - platformOne.platformHeight - platformTwo.platformHeight - platformThree.platformHeight);

            platformFive = new TiledPlatform(cm, sb, gdm, false, true, true, true);
            platformFive.platformSize = new Vector2(5, 5);
            platformFive.position     = new Vector2(map.getTileMapWidthInPixels / 2 - platformOne.platformWidth / 2 + platformThree.platformWidth, map.getTileMapHeightInPixels - platformOne.platformHeight - platformTwo.platformHeight - platformThree.platformHeight);

            hurdleOne = new Hurdle(cm, gdm, sb);
            hurdleOne.worldPosition = new Vector2(map.getTileMapWidthInPixels / 4, map.getTileMapHeightInPixels - hurdleOne.height);

            hurdleTwo = new Hurdle(cm, gdm, sb);
            hurdleTwo.worldPosition = new Vector2(map.getTileMapWidthInPixels / 2 - 400, map.getTileMapHeightInPixels - platformOne.platformHeight - hurdleTwo.height);

            momentumButtonOne = new MomentumActionButton(cm, gdm, sb, new Vector2(15, -25));
            momentumButtonOne.worldPosition = new Vector2(map.getTileMapWidthInPixels / 2 - momentumButtonOne.width / 2, platformOne.position.Y - 200);

            gravity = new Vector2(0, 9);
        }
示例#5
0
        //TO DO: make an environment class for the stages to pass in so I know how to modify the movement accordingly
        // potential modifiers: wind, terrain slickness(may just handle this in the wall collision class), gravity, etc
        // in the mean time just keep track of items individually
        public Vector2 calculateNewPosition(Vector2 gravity)
        {
            //saves the old position before modifying it and updating it accordingly
            previousWorldPosition = currentWorldPosition;
            Vector2 newPosition = currentWorldPosition;

            if (actionStateIsActive)
            {
                if (hurdleActionStateActive) {
                    if (currentActionHurdleReference != null) {
                        //TO DO: have it run through the hurdle's action state sequence here
                        if (upTheHurdle) {
                            hurdleTimer++;
                            if (movingLeft) {
                                newPosition.X += hurdleDistance.X/hurdleTimerMax;
                            }
                            if (movingRight) {
                                newPosition.X -= hurdleDistance.X / hurdleTimerMax;
                            }
                            newPosition.Y -= hurdleDistance.Y/hurdleTimerMax;

                            if (hurdleTimer > hurdleTimerMax) {
                                upTheHurdle = false;
                                overTheHurdle = true;
                                if (movingLeft) {
                                    hurdleDistance.X = currentActionHurdleReference.getBoundingBox.Left - boundingRectangle.Right;
                                }
                                if (movingRight) {
                                    hurdleDistance.X = currentActionHurdleReference.getBoundingBox.Right - boundingRectangle.Left;
                                }
                                hurdleDistance.Y = currentActionHurdleReference.getBoundingBox.Top - boundingRectangle.Bottom;
                                hurdleTimer = 0;
                                hurdleTimerMax = 10;
                            }
                        }

                        if (overTheHurdle) {
                            hurdleTimer++;
                            newPosition.X += hurdleDistance.X / hurdleTimerMax;
                            newPosition.Y -= hurdleDistance.Y / hurdleTimerMax;
                            if (hurdleTimer > hurdleTimerMax) {
                                overTheHurdle = false;
                                if (movingLeft) {
                                    momentum.X = -50;
                                }
                                if (movingRight) {
                                    momentum.X = 50;
                                }
                            }
                        }

                        if (!upTheHurdle && !overTheHurdle) {
                            hurdleActionStateActive = false;
                        }
                    }
                    else {
                        hurdleActionStateActive = false;
                    }

                    //resets the action state flag if nothing is pressed
                    if (hurdleActionStateActive) {
                        actionStateIsActive = true;
                    }
                    else {
                        currentActionHurdleReference = null;
                        actionStateIsActive = false;
                    }
                }
                return newPosition;
            }
            else {
                //accounts for movement in these directions
                if (movingLeft)
                {
                    newPosition.X -= velocity.X;
                }
                if (movingRight)
                {
                    newPosition.X += velocity.X;
                }

                //accounts for the action states, standing, jumping, falling, dashing
                if (isJumping)
                {
                    if (jumpTimer < jumpTimerMax)
                    {
                        //This basically ups the velocity of the player and diminishes it based on the duration of the jump, the longer the jump the less high you will go
                        //Abe:  If you want to do it based on progress, use a parabolic velocity function - e.g. x(t) = v * t * cos(angle), y(t) = v * t * sin(angle) - 0.5 * g * t^2
                        if (isDashing)
                        {
                            //don't update player jump values
                        }
                        else
                        {
                            newPosition.Y -= velocity.Y - (velocity.Y * ((float)jumpTimer / (float)jumpTimerMax));
                        }
                    }
                    else
                    {
                        isJumping = false;
                        //possibly set the falling animation here and then on any collision have the player check if they're falling and set the animation accordingly
                        isFalling = true;
                        playerImageSheet.setFrameConfiguration(72, 72, 72);
                        playerImageSheet.frameTimeLimit = 8;
                    }
                    jumpTimer++;
                    //System.Diagnostics.Debug.WriteLine(jumpTimer);
                }
                if (isFalling)
                {
                    //if falling this is added to counteract gravity, set to 0 for no effect or remove as well
                    if (isDashing)
                    {
                        //dont update vector
                    }
                    else
                    {
                        newPosition -= new Vector2(0, 6);
                    }
                }
                //tracks dashing modifiers, if dashing and within the duration modifies the position accordingly
                //else it's outside duration and sets dashing to false, but that it's been exhausted, the exhaustedDash
                //needs to be reset by collision objects otherwise it breaks
                if (isDashing)
                {
                    if (dashTimer < dashTimerMax &&
                        exhaustedDash == false)
                    {
                        //if you want to be able to dash without having to move change these to "facingLeft" and "facingRight"
                        if (facingLeft)
                        {
                            newPosition.X -= 10f;
                        }
                        if (facingRight)
                        {
                            newPosition.X += 10f;
                        }
                    }
                    else
                    {
                        isDashing = false;
                        exhaustedDash = true;
                        if ((movingLeft || movingRight) && (!isFalling && !isFallingFromGravity && !isJumping))
                        {
                            playerImageSheet.setFrameConfiguration(18, 18, 25);
                            playerImageSheet.frameTimeLimit = 8;
                        }
                        else
                        {
                            if (isFalling)
                            {
                                playerImageSheet.setFrameConfiguration(72, 72, 72);
                                playerImageSheet.frameTimeLimit = 8;
                            }
                            else if (isFallingFromGravity)
                            {
                                playerImageSheet.setFrameConfiguration(73, 73, 73);
                                playerImageSheet.frameTimeLimit = 8;
                            }
                            else if (isJumping)
                            {
                                playerImageSheet.setFrameConfiguration(36, 36, 42);
                                playerImageSheet.frameTimeLimit = 6;
                            }
                        }
                    }
                    dashTimer++;
                }

                //adds environment modifying vectors
                if (isJumping || isDashing)
                {
                    newPosition -= gravity;
                }

                newPosition += gravity;

                newPosition += momentum;
                momentum.X = (float)(momentum.X *.9);
                momentum.Y = (float)(momentum.Y*.9);

                return newPosition;
            }
        }