ssoni

MoveGuy_NoDelay

Apr 19th, 2021
474
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.     Public pressingLeft As Boolean
  3.     Public pressingRight As Boolean
  4.     Public pressingUp As Boolean
  5.     Public pressingDown As Boolean
  6.  
  7.     Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
  8.         If e.KeyCode = Keys.Right Then
  9.             pressingRight = True
  10.         ElseIf e.KeyCode = Keys.Left Then
  11.             pressingLeft = True
  12.         ElseIf e.KeyCode = Keys.Up Then
  13.             pressingUp = True
  14.         ElseIf e.KeyCode = Keys.Down Then
  15.             pressingDown = True
  16.         End If
  17.     End Sub
  18.  
  19.     Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
  20.         If e.KeyCode = Keys.Right Then
  21.             pressingRight = False
  22.         ElseIf e.KeyCode = Keys.Left Then
  23.             pressingLeft = False
  24.         ElseIf e.KeyCode = Keys.Up Then
  25.             pressingUp = False
  26.         ElseIf e.KeyCode = Keys.Down Then
  27.             pressingDown = False
  28.         End If
  29.     End Sub
  30.  
  31.     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles tmrMoveGuy.Tick
  32.         If pressingRight = True Then
  33.             picMario.Left = picMario.Left + 10
  34.             picMario.Image = My.Resources.marioRight
  35.         ElseIf pressingleft = True Then
  36.             picMario.Left = picMario.Left - 10
  37.             picMario.Image = My.Resources.marioLeft
  38.         ElseIf pressingup = True Then
  39.             picMario.Top = picMario.Top - 10
  40.             picMario.Image = My.Resources.marioUp
  41.         ElseIf pressingdown = True Then
  42.             picMario.Top = picMario.Top + 10
  43.             picMario.Image = My.Resources.marioDown
  44.         End If
  45.  
  46.     End Sub
  47.  
  48.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  49.  
  50.     End Sub
  51. End Class
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×