我目前正在攻读高等计算机科学专业,我选择为我的项目制作小行星。我刚刚开始,但到目前为止这是我的代码:
Public Class Form1
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.D OrElse e.KeyData = Keys.Right Then
Spaceship.Left += 3
End If
If e.KeyData = Keys.A OrElse e.KeyData = Keys.Left Then
Spaceship.Left -= 3
End If
If e.KeyData = Keys.W OrElse e.KeyData = Keys.Up Then
Spaceship.Top -= 3
End If
If e.KeyData = Keys.S OrElse e.KeyData = Keys.Down Then
Spaceship.Top += 3
End If
Refresh()
If e.KeyData = Keys.Space Then
' generate a bullet which continues in a straight line until it hits something
End If
If e.KeyData = Keys.Escape Then
End
End If
End Sub
End Class
如您所见,我允许用户关闭表格并使用箭头键移动太空飞船。但是,我需要以下方面的帮助:
所有人,并提前感谢。