Ejemplo n.º 1
0
        public Obstacle CreateJumpObstacle(LevelElementPlacement placement, float groundY)
        {
            float centerOfObstacle = GetXPositionByTime(placement.SynchroStartTime) +
                                     PhysicsValues.GetPlainJumpLength() / 2.0f;

            float halfObstacleWidth = LevelGenerationValues.GetJumpObstacleWidth() / 2.0f;

            float leftX  = centerOfObstacle - halfObstacleWidth;
            float rightX = centerOfObstacle + halfObstacleWidth;

            float topY = groundY + LevelGenerationValues.GetJumpObstacleHeight();

            return(new Obstacle(new Vector2(leftX, topY), new Vector2(rightX, groundY)));
        }
Ejemplo n.º 2
0
        public static float GetJumpObstacleWidth()
        {
            float minimumHorizontalDistanceRequired = 0;

            for (float time = 0; time < 100; time += 1.0f / GeneralValues.FPS)
            {
                if (GetYDifferenceAfterJump(time) > GetJumpObstacleHeight())
                {
                    minimumHorizontalDistanceRequired = time * PhysicsValues.GetHorizontalPlayerVelocity();
                    break;
                }
            }

            float halfJumpObstacleWidth = PhysicsValues.GetPlainJumpLength() / 2.0f;

            halfJumpObstacleWidth -= MaximumJumpObstacleJumpTimingOffset * PhysicsValues.GetHorizontalPlayerVelocity();
            halfJumpObstacleWidth -= minimumHorizontalDistanceRequired;
            halfJumpObstacleWidth -= PhysicsValues.GetHalfPlayerHitboxWidth();

            return(halfJumpObstacleWidth * 2 * GeneralValues.DifficultyFactor);
        }