In this 21st episode, we'll look at horizontally moving walls.  This is probably one of the more
challenging aspects of platforming, simply because of the fact that, first of all, the wall is 
moving and our boundaries would have to be moving with the wall.  We can solve this by moving the
boundaries along with the wall.  We'd also have to get the character to ride the wall, instead of
doing it as in some games, where you have to walk to stay on the wall.  Then, there are other
problems with the wall.  We'd have to move the character if the wall moves into the character.  We
then have to kill the character if the wall rams him into another wall or something.  So, there's
a lot at stake here.
The first question: What do we use for these moving walls?  Well, we can easily make a structure 
for our moving wall.  This structure would have the location of the wall.  It would also hold the
speed of the moving wall in the X and Y directions.  Also, we have not determined how far the wall
will move, so we'd also need to specify some boundaries for our moving wall.

Public Structure MovingWall
    Private rect As Rectangle  'The location of the wall.
    Private cx As Integer       'How much the wall moves in the horizontal.
    Private cy As Integer       'How much the wall moves in the vertical.
    Private bound As Rectangle  'The wall cannot move outside of this square.
    Public Property Loc() As Rectangle
        Get
            Return rect
        End Get
        Set(ByVal Value As Rectangle)
            rect = Value
        End Set
    End Property
    Public Property dX() As Integer
        Get
            Return cx
        End Get
        Set(ByVal Value As Integer)
            cx = Value
        End Set
    End Property
    Public Property dY() As Integer
        Get
            Return cy
        End Get
        Set(ByVal Value As Integer)
            cy = Value
        End Set
    End Property
    Public Property Boundary() As Rectangle
        Get
            Return bound
        End Get
        Set(ByVal Value As Rectangle)
            bound = Value
        End Set
    End Property
    Public Sub New(ByVal R As Rectangle, ByVal dX As Integer, ByVal dY As Integer, ByVal Boundary As Rectangle)
        Me.rect = R
        Me.cx = dX
        Me.cy = dY
        Me.bound = Boundary
    End Sub
    Public Sub Offset(ByVal dX As Integer, ByVal dY As Integer)
        rect.Offset(dX, dY)
    End Sub
End Structure
This is our structure for moving walls. Now, something nifty that we could add is the ability for this structure to move the wall inside on its own instead of making all of the calculations go into the CharacterMovement sub and take up space. This will mean that there are fewer lines in the loop that iterates through all of the moving walls, and cleaner code. So, about the movement: we simply move the wall by offseting it by cx and cy at each tick of the clock. This is what we'll do inside of the structure: move the wall by cx and cy in some subroutine. This single subroutine will be called in the Charactermovement when the wall needs to be moved. So, let's add this routine to our Structure above.
    Public Sub MoveWall()
        'This subroutine coordinates the in-game functionality of the moving wall with the rest of the game.
        'Just add the collision checks against rect.
        rect.Offset(cx, cy) 'Move the wall.
        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
        If rect.Bottom > bound.Bottom OrElse rect.Top < bound.Top Then
            'This is for vertical movement direction switching.
            cy = -cy
        End If
    End Sub
And this structure is finished. Now, we just need to make this structure work with our game. Of course, we first declare our arraylist that contains all of the moving walls.
    Dim MobileWalls As ArrayList
    'Holds all of the moving walls in the level.
    Dim MobileWall As MovingWall
    'A moving wall structure variable declaration
Then, we set up the arraylist to a new instance so it can be used.
        MobileWalls = New ArrayList(20)
        'Set up the arraylist.
        MobileWalls.Add(New MovingWall(New Rectangle(640, 80, 32, 32), 4, 0, New Rectangle(500, 0, 300, 600)))
        'Add a moving wall.
And then, we move the wall in the CharacterMovement. This goes before the IsJumping If block.
            Dim R As Integer
            For R = 0 To MobileWalls.Count - 1
                MobileWall = DirectCast(MobileWalls(R), MovingWall)
                'We have to use DirectCast since arraylist contains structures and we are changing the property values.
                MobileWall.MoveWall()
                'This does all of the movement for the wall.
                MobileWalls(R) = MobileWall
            Next
Of course, we now have to draw the wall in the artwork subroutine.
        For Each MobileWall In MobileWalls
            MobileWall.Offset(-ScreenLeft, -ScreenTop)
            GFX.FillRectangle(Brushes.DarkKhaki, MobileWall.Loc)
            GFX.DrawRectangle(Pens.Sienna, MobileWall.Loc)
            'This will draw the wall (not the boundary).
            MobileWall.Offset(ScreenLeft, ScreenTop)
            'We must reset the wall location.
        Next
OK, due to interest, I'm going to stretch this part of the tutorial out so that it can be made available, but next time we'll get the player to land on the walls.