Andddddddd we have movement :D
Using this little section of code
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Dim Loc As Point
Select Case e.KeyCode
Case Keys.Up
If Not ImgChar.Location.Y - 50 < 0 Then
Loc = New Point(ImgChar.Location.X, ImgChar.Location.Y - 50)
ImgChar.Location = Loc
End If
Case Keys.Down
If Not ImgChar.Location.Y + 50 > 450 Then
Loc = New Point(ImgChar.Location.X, ImgChar.Location.Y + 50)
ImgChar.Location = Loc
End If
Case Keys.Left
If Not ImgChar.Location.X - 50 < 0 Then
Loc = New Point(ImgChar.Location.X - 50, ImgChar.Location.Y)
ImgChar.Location = Loc
End If
Case Keys.Right
If Not ImgChar.Location.X + 50 > 450 Then
Loc = New Point(ImgChar.Location.X + 50, ImgChar.Location.Y)
ImgChar.Location = Loc
End If
End Select
End Sub
I've made a little blue square move around my form, its a miracle!
Next stop will be to try and get my program to draw an 8x8 grid and fill them with a colour (green probably)
No comments:
Post a Comment