sorry for sending another question back in so quickly, but I need help. I'm trying to get a picture box to move when you press a button. that's the part that is a problem. I tried it on my own at first, then I looked up some stuff, then I even took some code from a different answer on this website, but none of it works. I know it seems easy to you guys, but it is not for me. please help. by the way, kirby_Pic is the thing I'm trying to move.
Imports System.CodeDom
Public Class Form1
Private Sub Leave_Btn_Click(sender As Object, e As EventArgs) Handles Leave_Btn.Click
End
End Sub
Private Sub Collision(sender As Object, e As EventArgs)
If Kirby_Pic.Bounds.IntersectsWith(BrontoBurt_Pic.Bounds) Then
Kirby_Pic.Location = New Point(21, 97)
ElseIf Kirby_Pic.Bounds.IntersectsWith(WaddleDee_Pic.Bounds) Then
Kirby_Pic.Location = New Point(21, 97)
End If
End Sub
Dim inputX, inputY As Integer
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.W : inputY = -1
Case Keys.S : inputY = 1
Case Keys.A : inputX = -1
Case Keys.D : inputX = 1
End Select
End Sub
Dim velocity As Integer = 4
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim newx = Kirby_Pic.Location.X + velocity * inputX
newx = Math.Min(Math.Max(0, newx), Me.ClientSize.Width - Kirby_Pic.Width)
Dim newy = Kirby_Pic.Location.Y + velocity * inputY
newy = Math.Min(Math.Max(0, newy), Me.ClientSize.Height - Kirby_Pic.Height)
Kirby_Pic.Location = New Point(newx, newy)
End Sub
End Class