src/main/flappybird/MoWall.java
// based on the previous walls x-position
based on the previous walls x-position
based on the previous walls x - position
private void initWalls(MoWall previousWall) {
        double firstHeightScale = MoFunctions.getRandom(MIN_HEIGHT_SCALE,MAX_HEIGHT_SCALE);
        double secondHeightScale = MAX_HEIGHT_SCALE - firstHeightScale;
        double previousPositionX = previousWall == null ? BASE_X_POSITION : previousWall.getPositionX();
        double previousWallWidth = previousWall == null ? 0 : previousWall.getWalls().get(0).getWidth();
        double width = MoFunctions.getRandom(MIN_WIDTH,MAX_WIDTH);
        for (int i = 0; i < MAX_WALLS; i++) {
            int height =  (i == 0) ? (int) (firstHeightScale * MoConstants.GROUND_LEVEL_Y) :
                    (int) (secondHeightScale * MoConstants.GROUND_LEVEL_Y);
            MoAnimatableObject moAnimatableObject = new MoAnimatableObject(
                    (int) (previousPositionX + MIN_DISTANCE_AFTER_WALL + previousWallWidth),
                     i == 0 ? (int) (MoConstants.GROUND_LEVEL_Y - height)
                            : 0,
                    (int) width, height, X_VEL, Y_VEL,
                    0
            );
            this.walls.add(moAnimatableObject);
        }
        this.initSafeGap();
    }
private void initWalls ( MoWall previousWall ) { double firstHeightScale = MoFunctions . getRandom ( MIN_HEIGHT_SCALE , MAX_HEIGHT_SCALE ) ; double secondHeightScale = MAX_HEIGHT_SCALE - firstHeightScale ; double previousPositionX = previousWall == null ? BASE_X_POSITION : previousWall . getPositionX ( ) ; double previousWallWidth = previousWall == null ? 0 : previousWall . getWalls ( ) . get ( 0 ) . getWidth ( ) ; double width = MoFunctions . getRandom ( MIN_WIDTH , MAX_WIDTH ) ; for ( int i = 0 ; i < MAX_WALLS ; i ++ ) { int height = ( i == 0 ) ? ( int ) ( firstHeightScale * MoConstants . GROUND_LEVEL_Y ) : ( int ) ( secondHeightScale * MoConstants . GROUND_LEVEL_Y ) ; MoAnimatableObject moAnimatableObject = new MoAnimatableObject ( ( int ) ( previousPositionX + MIN_DISTANCE_AFTER_WALL + previousWallWidth ) , i == 0 ? ( int ) ( MoConstants . GROUND_LEVEL_Y - height ) : 0 , ( int ) width , height , X_VEL , Y_VEL , 0 ) ; this . walls . add ( moAnimatableObject ) ; } this . initSafeGap ( ) ; }
based on the previous walls x-position
based on the previous walls x - position