Hallo!
Arbeite derzeit an einem kleinen 2d jump'n'run (oder Platform) Spielchen! Mein Problem ist Folgendes:
Wenn ich die UP Taste betätige (also einen Sprung simuliere), kann ich während des Sprungs weder nach rechts noch nach links gehen.
Quellcode:
frmMain
Module1
Danke im Voraus!
Aydo
Arbeite derzeit an einem kleinen 2d jump'n'run (oder Platform) Spielchen! Mein Problem ist Folgendes:
Wenn ich die UP Taste betätige (also einen Sprung simuliere), kann ich während des Sprungs weder nach rechts noch nach links gehen.
Quellcode:
frmMain
VB.NET-Quellcode
- Public Class frmMain
- Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
- If e.KeyCode < 40 Then keyarray(e.KeyCode) = True
- End Sub
- Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
- If e.KeyCode < 40 Then keyarray(e.KeyCode) = False
- End Sub
- Private Sub tmrGameTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGameTimer.Tick
- If keyarray(37) = True Then
- If imgPlayer.Left > 100 Then
- imgPlayer.Left = imgPlayer.Left - 10
- Else
- If imgBackground.Left >= 0 Then
- Else
- imgBackground.Left = imgBackground.Left + 10
- imgBottom.Left = imgBottom.Left + 10
- imgBrick.Left = imgBrick.Left + 10
- End If
- End If
- End If
- If keyarray(39) = True Then
- If imgPlayer.Left < 600 Then
- imgPlayer.Left = imgPlayer.Left + 10
- Else
- If imgBackground.Left <= -4200 Then
- Else
- imgBackground.Left = imgBackground.Left - 10
- imgBottom.Left = imgBottom.Left - 10
- imgBrick.Left = imgBrick.Left - 10
- End If
- End If
- End If
- If keyarray(38) = True Then
- Dim Jump As Integer = 0
- Do Until Jump = 10
- imgPlayer.Top = imgPlayer.Top - 10
- Jump = Jump + 1
- System.Threading.Thread.Sleep(5)
- Me.Refresh()
- Loop
- Do Until Jump = 0
- imgPlayer.Top = imgPlayer.Top + 10
- Jump = Jump - 1
- System.Threading.Thread.Sleep(5)
- Me.Refresh()
- Loop
- tmrJump.Enabled = False
- End If
- End Sub
- Private Sub tmrCurrentPos_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCurrentPos.Tick
- lblPlayerX.Text = "X:" & imgPlayer.Location.X
- lblPlayerY.Text = "Y:" & imgPlayer.Location.Y
- End Sub
- End Class
Module1
Danke im Voraus!
Aydo