Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Me.AutoScroll = False
- Upp = True
- Downn = True
- Leftt = True
- Rightt = True
- My.Computer.Audio.Play(My.Resources.alternative_theme, AudioPlayMode.Background)
- End Sub
- Private Sub MapBounds()
- 'Create map boundaries
- Dim xx As Integer = picLink.Location.X
- Dim yy As Integer = picLink.Location.Y
- If xx <= 16 Then
- Leftt = False
- Else
- Leftt = True
- End If
- If yy <= 16 Then
- Upp = False
- Else
- Upp = True
- End If
- If xx >= 720 Then
- Rightt = False
- Else
- Rightt = True
- End If
- If yy >= 480 Then
- Downn = False
- Else
- Downn = True
- End If
- End Sub
- Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
- 'Initialize boundaries
- MapBounds()
- 'Make the sprite move
- 'Case 1) move right
- 'Case 2) move left
- 'Case 3) move up
- 'Case 4) move down
- Select Case e.KeyCode
- Case Keys.Right
- If Rightt = True Then
- tmrRight.Enabled = True
- tmrLeft.Enabled = False
- tmrDown.Enabled = False
- tmrUp.Enabled = False
- End If
- 'set the collisions for any rock that can be hit from the right side(walls included)
- If picLink.Bounds.IntersectsWith(picRock1.Bounds) Then
- tmrRight.Enabled = False
- CurrentLocation = New Point(picLink.Location.X - 8, picLink.Location.Y) 'New Picture Location
- picLink.Location = CurrentLocation 'Set Location
- End If
- Case Keys.Left
- If Leftt = True Then
- tmrLeft.Enabled = True
- tmrRight.Enabled = False
- tmrDown.Enabled = False
- tmrUp.Enabled = False
- End If
- Case Keys.Up
- If Upp = True Then
- tmrUp.Enabled = True
- tmrLeft.Enabled = False
- tmrRight.Enabled = False
- tmrDown.Enabled = False
- End If
- Case Keys.Down
- If Downn = True Then
- tmrDown.Enabled = True
- tmrUp.Enabled = False
- tmrLeft.Enabled = False
- tmrRight.Enabled = False
- End If
- End Select
- End Sub
- Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
- Select Case e.KeyCode
- Case Keys.D
- tmrRight.Enabled = False
- Case Keys.A
- tmrLeft.Enabled = False
- Case Keys.W
- tmrUp.Enabled = False
- Case Keys.S
- tmrDown.Enabled = False
- End Select
- End Sub
- Private Sub TmrRight_Tick(sender As Object, e As EventArgs) Handles tmrRight.Tick
- If Not picLink.Location.X + 8 > 720 Then 'If not Out Of Screen Bounds
- CurrentLocation = New Point(picLink.Location.X + 8, picLink.Location.Y) 'Move Right
- picLink.Location = CurrentLocation 'Set New Location
- End If
- End Sub
- Private Sub TmrLeft_Tick(sender As Object, e As EventArgs) Handles tmrLeft.Tick
- If Not picLink.Location.X - 8 < 16 Then 'If Not Out Of Screen Bounds
- CurrentLocation = New Point(picLink.Location.X - 8, picLink.Location.Y) 'New Picture Location
- picLink.Location = CurrentLocation 'Set Location
- End If
- End Sub
- Private Sub TmrUp_Tick(sender As Object, e As EventArgs) Handles tmrUp.Tick
- If Not picLink.Location.Y - 8 < 16 Then 'If Not Out Of Top Frame
- CurrentLocation = New Point(picLink.Location.X, picLink.Location.Y - 8) 'Move Up
- picLink.Location = CurrentLocation 'Record New Location
- End If
- End Sub
- Private Sub TmrDown_Tick(sender As Object, e As EventArgs) Handles tmrDown.Tick
- If Not picLink.Location.Y - 8 > 480 Then 'If Not Out Of Bottom Bounds
- CurrentLocation = New Point(picLink.Location.X, picLink.Location.Y + 8) 'Move Down
- picLink.Location = CurrentLocation
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement