```You knew it was coming eventually - vertically moving walls.
Fortunately, our MovingWall structure should properly handle all vertical movement.
The only thing we need to add is smush tests.  While this may seem to be pretty easy
since all vertical movement collisions concerning moving walls would smush the player,
things get complicated if the wall is moving horizontally and vertically.  If the player
on the moving wall collides with a wall, we need some way of determining if the player
collided with the wall vertically or horizontally.  We've already done horizontal
pushing and smushing, and all vertical walls coming together smush the player (you can't
move the player back down into the wall), but since the moving walls do these at the same
time by themselves, we cannot check which movement direction caused the player to collide
with the wall.
So, we need to remodel the MovingWall Structure so that, at the least, we can make the
horizontal and vertical movements into separate calls.
Public Sub MoveHorizontal()
'This subroutine does just like the Movewall does, but only in the horizontal, with cx, left and right.
rect.Offset(cx, 0) 'Move.
If rect.Right > bound.Right OrElse rect.Left < bound.Left Then
'When the wall hits the edge of our boundary, then it must begin moving in the other direction.
cx = -cx
End If
End Sub
Public Sub MoveVertical()
'Same as MoveWall, but only in the vertical, with cy, top and bottom.
rect.Offset(0, cy) 'Move.
If rect.Bottom > bound.Bottom OrElse rect.Top < bound.Top Then
'This is for vertical movement direction switching.
cy = -cy
End If
End Sub
After we make these changes, we can go into the section of the code that we
added last time to check if the moving wall moved into the player and then change all of
our calls to .MoveWall into two calls: one to .MoveHorizontal and one to .MoveVertical.
Yes, even the one in the little else statement should be replaced with Horizontal.
The call to .MoveHorizontal goes in place of the previous call to .MoveWall, because
after the wall moves horizontally, we check for all of the pushing in the horizontal
direction.  The .MoveVertical goes after all of this (outside of the whole block), and
if any collisions occur here, then the player is smushed.
If MobileWall.dX < 0 Then
'The wall is moving left.
MobileWall.MoveHorizontal()
'This does horizontal movement for the wall.
If MobileWall.Loc.IntersectsWith(PlayerLoc) Then
If Not TouchingWall Then
'Move the player to the left side of this wall.
PlayerLoc.Offset(MobileWall.Loc.Left - PlayerLoc.Right, 0)
TouchingWall = True
If PlayerLoc.Right < LeftEnd AndAlso Not IsJumping Then
IsJumping = True
'We are not really jumping, but we are falling.
MobileIndex = -1
'We are not standing on anything now, because we are jumping.
PlayerVeloc = 0
'Since we are falling from rest, the initial velocity will be zero.
End If
Else
IsGoner = True
'The player has been smushed.  Lose a life.
PlayerVeloc = SBARINITIALVELOCITY
End If
End If

ElseIf MobileWall.dX > 0 Then
'The wall is moving right.
MobileWall.MoveHorizontal()
'This does all of the movement for the wall.
If MobileWall.Loc.IntersectsWith(PlayerLoc) Then
If Not TouchingWall Then
'Move the player to the right side of this wall.
PlayerLoc.Offset(MobileWall.Loc.Right - PlayerLoc.Left, 0)
TouchingWall = True
If PlayerLoc.Left > RightEnd AndAlso Not IsJumping Then
IsJumping = True
'We are falling.
MobileIndex = -1
'We are not standing on anything now, because we are jumping.
PlayerVeloc = 0
'A fall from rest.
End If
Else
IsGoner = True
'The player has been smushed.  Lose a life.
PlayerVeloc = SBARINITIALVELOCITY
End If
End If
Else
MobileWall.MoveHorizontal()
'This does all of the movement for the wall.
End If
MobileWall.MoveVertical()
'Vertical movement here.
If MobileWall.Loc.IntersectsWith(PlayerLoc) Then
If Not IsJumping Then
IsGoner = True
'The player has been smushed.  Lose a life.
PlayerVeloc = SBARINITIALVELOCITY

End If
End If
This is the player getting smushed by a moving wall falling onto his head.  We also need
to check if the player is smushed upwards into another wall by moving up.  For this, we
go back up to where we moved the player.
Of course, we should first only move the player in the horizontal direction before doing
the wall tests that follow, so the call to PlayerLoc.Offset should be
PlayerLoc.Offset(MobileWall.dX, 0)
After the loop through all of the walls, we move the player vertically and then check
for vertical collision.  Again, we'll smush the player here.
PlayerLoc.Offset(0, MobileWall.dY)

For Each Wall In Walls
If PlayerLoc.IntersectsWith(Wall) Then
IsGoner = True
'The player has been smushed.  Lose a life.
PlayerVeloc = SBARINITIALVELOCITY

End If
Next
The only thing left to implement is when the player is smushed between two moving walls.
A nice fix would be to check all of the moving walls after the player moves up.  However,
our mobilewall loop variable is already in use.  But, instead we can reassign the loop
value after we get finished checking the wall.  The index we need is still in R, so we
can use that to get the original moving wall.
For Each MobileWall In MobileWalls
If PlayerLoc.IntersectsWith(MobileWall.Loc) Then
IsGoner = True
'The player has been smushed.  Lose a life.
PlayerVeloc = SBARINITIALVELOCITY
End If
Next
MobileWall = DirectCast(MobileWalls(R), MovingWall)
Now all of our Vertical Movement should be complete.  Next, we'll get on to the process
of getting these MovingWalls to work with the Editor.
```