Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.  
  3. Me.AutoScroll = False
  4.  
  5. Upp = True
  6. Downn = True
  7. Leftt = True
  8. Rightt = True
  9.  
  10. My.Computer.Audio.Play(My.Resources.alternative_theme, AudioPlayMode.Background)
  11.  
  12.  
  13.  
  14. End Sub
  15. Private Sub MapBounds()
  16. 'Create map boundaries
  17. Dim xx As Integer = picLink.Location.X
  18. Dim yy As Integer = picLink.Location.Y
  19.  
  20. If xx <= 16 Then
  21. Leftt = False
  22. Else
  23. Leftt = True
  24. End If
  25.  
  26. If yy <= 16 Then
  27. Upp = False
  28. Else
  29. Upp = True
  30. End If
  31.  
  32. If xx >= 720 Then
  33. Rightt = False
  34. Else
  35. Rightt = True
  36. End If
  37.  
  38. If yy >= 480 Then
  39. Downn = False
  40. Else
  41. Downn = True
  42. End If
  43. End Sub
  44.  
  45. Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
  46.  
  47. 'Initialize boundaries
  48. MapBounds()
  49.  
  50. 'Make the sprite move
  51. 'Case 1) move right
  52. 'Case 2) move left
  53. 'Case 3) move up
  54. 'Case 4) move down
  55.  
  56. Select Case e.KeyCode
  57. Case Keys.Right
  58. If Rightt = True Then
  59. tmrRight.Enabled = True
  60. tmrLeft.Enabled = False
  61. tmrDown.Enabled = False
  62. tmrUp.Enabled = False
  63. End If
  64. 'set the collisions for any rock that can be hit from the right side(walls included)
  65. If picLink.Bounds.IntersectsWith(picRock1.Bounds) Then
  66. tmrRight.Enabled = False
  67. CurrentLocation = New Point(picLink.Location.X - 8, picLink.Location.Y) 'New Picture Location
  68.  
  69. picLink.Location = CurrentLocation 'Set Location
  70. End If
  71.  
  72. Case Keys.Left
  73. If Leftt = True Then
  74. tmrLeft.Enabled = True
  75. tmrRight.Enabled = False
  76. tmrDown.Enabled = False
  77. tmrUp.Enabled = False
  78. End If
  79.  
  80. Case Keys.Up
  81. If Upp = True Then
  82. tmrUp.Enabled = True
  83. tmrLeft.Enabled = False
  84. tmrRight.Enabled = False
  85. tmrDown.Enabled = False
  86. End If
  87. Case Keys.Down
  88. If Downn = True Then
  89. tmrDown.Enabled = True
  90. tmrUp.Enabled = False
  91. tmrLeft.Enabled = False
  92. tmrRight.Enabled = False
  93. End If
  94. End Select
  95.  
  96.  
  97. End Sub
  98.  
  99. Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
  100. Select Case e.KeyCode
  101. Case Keys.D
  102. tmrRight.Enabled = False
  103. Case Keys.A
  104. tmrLeft.Enabled = False
  105. Case Keys.W
  106. tmrUp.Enabled = False
  107. Case Keys.S
  108. tmrDown.Enabled = False
  109.  
  110. End Select
  111. End Sub
  112.  
  113. Private Sub TmrRight_Tick(sender As Object, e As EventArgs) Handles tmrRight.Tick
  114. If Not picLink.Location.X + 8 > 720 Then 'If not Out Of Screen Bounds
  115.  
  116. CurrentLocation = New Point(picLink.Location.X + 8, picLink.Location.Y) 'Move Right
  117.  
  118. picLink.Location = CurrentLocation 'Set New Location
  119.  
  120. End If
  121. End Sub
  122.  
  123. Private Sub TmrLeft_Tick(sender As Object, e As EventArgs) Handles tmrLeft.Tick
  124. If Not picLink.Location.X - 8 < 16 Then 'If Not Out Of Screen Bounds
  125.  
  126. CurrentLocation = New Point(picLink.Location.X - 8, picLink.Location.Y) 'New Picture Location
  127.  
  128. picLink.Location = CurrentLocation 'Set Location
  129. End If
  130. End Sub
  131.  
  132. Private Sub TmrUp_Tick(sender As Object, e As EventArgs) Handles tmrUp.Tick
  133. If Not picLink.Location.Y - 8 < 16 Then 'If Not Out Of Top Frame
  134.  
  135. CurrentLocation = New Point(picLink.Location.X, picLink.Location.Y - 8) 'Move Up
  136.  
  137. picLink.Location = CurrentLocation 'Record New Location
  138.  
  139. End If
  140.  
  141. End Sub
  142.  
  143. Private Sub TmrDown_Tick(sender As Object, e As EventArgs) Handles tmrDown.Tick
  144. If Not picLink.Location.Y - 8 > 480 Then 'If Not Out Of Bottom Bounds
  145.  
  146. CurrentLocation = New Point(picLink.Location.X, picLink.Location.Y + 8) 'Move Down
  147.  
  148. picLink.Location = CurrentLocation
  149.  
  150. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement