Now, we are going to add walls to the game.  These are going to be the regular wall that you can't walk into in any kind
of way.  The player can walk on them, but cannot walk into them, or jump into them.  These walls will just be rectangles, so
they'll function as wall blocks, so that the player can actually jump on top of them.  But, there are a few catches to doing
this... .

But first, we are going to add collectibles to the project so that the somewhat bizarre discussion of walls can be 
explained simpler.
So, let's get a coin to go onto the form.  The coin picture can be found here:.
First of all, let's get one coin onto the form.

We need to add a Rectangle and a Bitmap declaration for the coin.

    Dim Coin As Rectangle
    'This holds the location of the coin.
    Dim CoinBmp As Bitmap
    'This contains the frames of the coin as it will be drawn onto the map.

    Const COINSIZE As Integer = 16
    'The width and height of the coin.
Coin is declared as a rectangle. When it is collected, we will empty the rectangle. When we go to draw our coin, we first check if the coin is visible. So, let's instantiate the coin (in Form_Load):
        Coin = New Rectangle(200, 550, COINSIZE, COINSIZE)
        CoinBmp = New Bitmap(Application.StartupPath & "\..\coin.bmp")
        'Initialize the coin location and picture.
        CoinBmp.MakeTransparent(Color.Magenta)
        'Clears the magenta colors in this bitmap.
Don't forget to move the coin bitmap into your solution directory. And let's draw it. To make it animate, we are just going to make a static variable in the Artwork subroutine. So, in the Artwork subroutine:
        Static Anim As Integer
        'Holds a number that coordinates animations.
Anim is a static integer that is going to count upwards forever. We can extract the data we need from it by just using Mod or an And operation. Since we are going to do an animation, we can get rid of the UpdateArtwork variable and checks/sets: So, let's add:
        Anim += 1
        'Increment the counter.
under our declaration And now, let's remove UpdateArtwork: Remove the If block in the Artwork subroutine, but leave the inside code intact, except for
            UpdateArtwork = False
            'Set it back to false.
Note that you don't *have* to remove these, it just makes the code simpler. Remove this from the IsJumping block of the CharacterMovement subroutine.
            UpdateArtwork = True
            'Need to update everytime during a jump.
Also, remove it from the GoLeft and GoRight blocks, which are right above the IsJumping block.
            UpdateArtwork = True
Remove it from the KeyUp procedure, remove the entire Paint procedure, and remove...
        'Make our drawing when the timer ticks.
        UpdateArtwork = True
...from the Load event procedure. We can remove the declaration now. Now that we have done that bit of pruning, we can easily draw our coin: Since anim counts up forever, we can break it into four cycles by using Mod: Anim Mod 4 which is equal to Anim And 3 but once again, let's pretend like we don't know how many frames are in the coin and use a constant instead. We can use another one for the
    Const COINFRAMECOUNT As Integer = 4
    'The number of frames in the coin bitmap.
COINFRAMECOUNT indicates how many frames are in the coin, which can be easily changed Now, our drawing looks like this:
        GFX.DrawImage(CoinBmp, Coin.X, Coin.Y, New Rectangle((Anim Mod COINFRAMECOUNT) * COINSIZE, 0, COINSIZE, COINSIZE), GraphicsUnit.Pixel)
        'Draws our spinning coin onto the form.
And that should make a coin appear on the form.
Now, to collect this coin, we will perform a collision detection with the player and the coin. This means that if the player and coin are touching, then the coin will be collected and turned into an empty rect. To do the collision detection, .NET has an easy way of detecting if two rectangles touch (intersect), which is in the Rectangle.IntersectsWith() function. So, in our CharacterMovement, after our character has moved to a new location, we perform the check:
        If Coin.IntersectsWith(PlayerLoc) Then
            Coin = Coin.Empty
            'Make the coin rectangle empty to indicate that we do not need to draw it.
        End If
And then, in the Artwork subroutine:
        If Not Coin.IsEmpty Then
            GFX.DrawImage(CoinBmp, Coin.X, Coin.Y, New Rectangle((Anim Mod COINFRAMECOUNT) * COINSIZE, 0, COINSIZE, COINSIZE), GraphicsUnit.Pixel)
            'Draws our spinning coin onto the form.
        End If
And now, the coin will disappear when you touch it.
Now... back to walls. Notice that we did a relatively simple check with the player and the coin. The wall check is much different because we are going to do more than one thing. The Rectangle.IntersectsWith() function can be expressed as: If A.IntersectsWith(B) Then = If A.Right > B.Left AndAlso B.Right > A.Left AndAlso A.Bottom > B.Top AndAlso B.Bottom > A.Top Then But, with the Wall, we need to check if the player has hit it from below, from above, from the left, or from the right. So, what do we do? As with all collision detection, we need to perform a check whenever the player moves. Due to the nature of our movement, we can first check if the player has walked into the wall within the GoLeft or GoRight blocks and just move the character back to the side of the wall. This will also handle the character's movements while he is jumping. The only condition left is Jumping, and we can check if the player landed on the block or hit it from beneath by checking the player's velocity. A negative velocity means the player is jumping up, which means he has hit the wall from beneath. Likewise, a positive velocity will make the player land on the wall. Now, we just check if the player has touched the wall. First, we need to make the wall rectangle.
    Dim Wall As Rectangle
    'Holds the location of the wall.
Then, we initialize the rectangle.
        Wall = Rectangle.FromLTRB(185, 415, 210, 465)
        'Wall is initialized.
Now, to draw the wall (in Artwork sub):
        GFX.FillRectangle(Brushes.Chocolate, Wall)
        GFX.DrawRectangle(Pens.BurlyWood, Wall)
        'This will draw the wall onto the form.
And finally, to make the character interact with the wall. This will have to be checked in the GoLeft and GoRight If blocks in addition to the IsJumping block of the CharacterMovement sub. Now, in the GoLeft block, we use .IntersectsWith to determine if the player has walked into the block.
            ElseIf PlayerLoc.IntersectsWith(Wall) Then
                PlayerLoc.Offset(Wall.Right - PlayerLoc.Left, 0)
                'Move the player to the edge of this wall.
In the GoRight block, we do the same, except the player moves back to the left.
            ElseIf PlayerLoc.IntersectsWith(Wall) Then
                PlayerLoc.Offset(Wall.Left - PlayerLoc.Right, 0)
                'Move the player to the edge of this wall.
And finally, in the IsJumping block, we do a check like this.
                If PlayerLoc.IntersectsWith(Wall) Then
                    If PlayerVeloc > 0 Then
                        'If player is falling, then the player will land on the wall.
                        IsJumping = False
                        'Stop the jump.
                        LeftEnd = Wall.Left : RightEnd = Wall.Right
                        'Set the endpoints.
                        AnimCycler = 0
                        'Reset the cycler.
                        PlayerLoc.Offset(0, Wall.Top - PlayerLoc.Bottom)
                        'Position the player to stand on this wall.
                    Else
                        'The player has jumped up into the wall.
                        PlayerLoc.Offset(0, Wall.Bottom - PlayerLoc.Top)
                        'Move the player to under the wall.
                        PlayerVeloc = 0
                        'Make the player start falling down.
                    End If
                End If
And that should do it for the wall. Next we'll go ahead and add arrways of coins and walls. At this point, you can download the current state of the project.